{"id":24437059,"url":"https://github.com/adclz/auto-lsp","last_synced_at":"2025-04-30T05:45:56.323Z","repository":{"id":273387272,"uuid":"879751096","full_name":"adclz/auto-lsp","owner":"adclz","description":"A rust crate for creating AST and LSP servers powered by tree-sitter queries.","archived":false,"fork":false,"pushed_at":"2025-04-29T17:09:14.000Z","size":2893,"stargazers_count":23,"open_issues_count":1,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-30T05:45:42.676Z","etag":null,"topics":["parsing","rust","tree-sitter","wasm"],"latest_commit_sha":null,"homepage":"https://adclz.github.io/auto-lsp/","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/adclz.png","metadata":{"files":{"readme":"README.MD","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.TXT","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-10-28T13:41:20.000Z","updated_at":"2025-04-29T17:07:10.000Z","dependencies_parsed_at":"2025-03-10T02:45:57.188Z","dependency_job_id":"7e3d26ea-00a0-4cd6-b4de-ba18051c982a","html_url":"https://github.com/adclz/auto-lsp","commit_stats":null,"previous_names":["adclz/auto-lsp"],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adclz%2Fauto-lsp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adclz%2Fauto-lsp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adclz%2Fauto-lsp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adclz%2Fauto-lsp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adclz","download_url":"https://codeload.github.com/adclz/auto-lsp/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251651222,"owners_count":21621702,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["parsing","rust","tree-sitter","wasm"],"created_at":"2025-01-20T18:15:00.865Z","updated_at":"2025-04-30T05:45:56.318Z","avatar_url":"https://github.com/adclz.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\" style=\"margin-bottom: 50px\"\u003e\r\n  \u003ch1\u003eAuto LSP\u003c/h1\u003e\r\n  \u003cp\u003e\r\n    \u003cstrong\u003eA Rust crate for creating \u003ca href=\"https://en.wikipedia.org/wiki/Abstract_syntax_tree\"\u003eAbstract Syntax Trees\u003c/a\u003e (AST)\r\nand \u003ca href=\"https://microsoft.github.io/language-server-protocol/\"\u003eLanguage Server Protocol\u003c/a\u003e (LSP) servers powered by \u003ca href=\"https://tree-sitter.github.io/tree-sitter/\"\u003eTree-sitter\u003c/a\u003e queries\u003c/strong\u003e\r\n  \u003c/p\u003e\r\n\r\n[![CI Status](https://github.com/adclz/auto-lsp/actions/workflows/ast-gen-native.yml/badge.svg)](https://github.com/adclz/auto-lsp/actions/workflows/ast-gen-native.yml)\r\n[![CI Status](https://github.com/adclz/auto-lsp/actions/workflows/lsp-server-native.yml/badge.svg)](https://github.com/adclz/auto-lsp/actions/workflows/lsp-server-native.yml)\r\n[![Book](https://img.shields.io/badge/📚-book-blue)](https://adclz.github.io/auto-lsp/)\r\n[![crates.io](https://img.shields.io/crates/v/auto-lsp)](https://crates.io/crates/auto-lsp)\r\n![Rust Version](https://img.shields.io/badge/rustc-1.83.0%2B-orange)\r\n\r\n\r\n\u003c/div\u003e\r\n\r\n\u003e `auto_lsp` is at an early stage, expect frequent breaking changes.\r\n\r\n# Quick Example\r\n\r\n`auto_lsp` is designed to be as language-agnostic as possible, allowing any Tree-sitter grammar to be used.\r\n\r\nDefining a simple AST involves two steps: writing the queries and then defining the corresponding AST structures in Rust.\r\n\r\nLet's say you have a toy language with a root node named **document** containing a list of **function** nodes, each containing a unique **name**.\r\n\r\nA simple query file to capture the root document and function names:\r\n\r\n```lisp\r\n(document) @document\r\n(function\r\n    (name) @name) @function\r\n```\r\n\r\nThe corresponding AST definition in Rust:\r\n\r\n```rust\r\n#[seq(query = \"document\")]\r\nstruct Document {\r\n   functions: Vec\u003cFunction\u003e\r\n}\r\n\r\n#[seq(query = \"function\")]\r\nstruct Function {\r\n   name: Name\r\n}\r\n\r\n#[seq(query = \"name\")]\r\nstruct Name {}\r\n```\r\n\r\nNow that you have your AST defined, you can:\r\n - Implement the [AST traits](https://adclz.github.io/auto-lsp/ast-and-queries/seq.html#seq-attributes) and create a LSP server (with the `lsp_server` feature).\r\n - Add your own logic for testing purposes, code generation, etc.\r\n\r\n# Documentation\r\n\r\n - [book](https://adclz.github.io/auto-lsp/)\r\n - [docs.rs](https://docs.rs/auto-lsp)\r\n\r\n## Examples\r\n\r\n - [HTML Ast](https://github.com/adclz/auto-lsp/blob/main/src/tests/html_workspace/mod.rs)\r\n - [Python Ast](https://github.com/adclz/auto-lsp/blob/main/src/tests/python_workspace/ast.rs)\r\n - [Simple LSP Server](https://github.com/adclz/auto-lsp/tree/main/examples/native)\r\n - [Vscode extension with WASI](https://github.com/adclz/auto-lsp/tree/main/examples/vscode-wasi)\r\n\r\n # Features\r\n\r\n- `lsp_server`: Enable the LSP server (uses [`lsp_server`](https://crates.io/crates/lsp-server)).\r\n- `wasm`: Enable wasm support (only compatible with `wasi-p1-threads`).\r\n- `html`: Enable the html workspace mock for testing purposes.\r\n- `python`: Enable the python workspace mock for testing purposes.\r\n\r\n# Inspirations / Similar projects\r\n\r\n- [Volar](https://volarjs.dev/)\r\n- [Rust-sitter](https://github.com/hydro-project/rust-sitter)\r\n- [StackGraphs](https://github.com/github/stack-graphs)\r\n- [airblast-dev](https://github.com/airblast-dev)'s [texter](https://github.com/airblast-dev/texter), which saved hours of headache\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadclz%2Fauto-lsp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadclz%2Fauto-lsp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadclz%2Fauto-lsp/lists"}