auto_lsp/lib.rs
1/*
2This file is part of auto-lsp.
3Copyright (C) 2025 CLAUZEL Adrien
4
5auto-lsp is free software: you can redistribute it and/or modify
6it under the terms of the GNU General Public License as published by
7the Free Software Foundation, either version 3 of the License, or
8(at your option) any later version.
9
10This program is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with this program. If not, see <http://www.gnu.org/licenses/>
17*/
18#![allow(rustdoc::private_intra_doc_links)]
19//!<div align="center" style="margin-bottom: 50px">
20//! <h1>Auto LSP</h1>
21//! <p>
22//! <strong>A Rust crate for creating <a href="https://en.wikipedia.org/wiki/Abstract_syntax_tree">Abstract Syntax Trees</a> (AST)
23//! and <a href="https://microsoft.github.io/language-server-protocol/">Language Server Protocol</a> (LSP) servers powered by <a href="https://tree-sitter.github.io/tree-sitter/">Tree-sitter</a></strong>
24//! </p>
25//!
26//! [](https://github.com/adclz/auto-lsp/actions/workflows/codegen.yml/)
27//! [](https://github.com/adclz/auto-lsp/actions/workflows/test-ast-native.yml)
28//! [](https://adclz.github.io/auto-lsp/)
29//! [](https://crates.io/crates/auto-lsp)
30//! 
31//!
32//!</div>
33//!
34//! `auto_lsp` is a generic library for creating Abstract Syntax Trees (AST) and Language Server Protocol (LSP) servers.//!
35//!
36//! It leverages crates such as [lsp_types](https://docs.rs/lsp-types/0.97/lsp_types/), [lsp_server](https://docs.rs/lsp-server/latest/lsp_server/), [salsa](https://docs.rs/salsa/latest/salsa/), and [texter](https://docs.rs/texter/latest/texter/), and generates the AST of a Tree-sitter language to simplify building LSP servers.
37//!
38//! `auto_lsp` provides useful abstractions while remaining flexible. You can override the default database as well as all LSP request and notification handlers.
39//!
40//! It is designed to be as language-agnostic as possible, allowing any Tree-sitter grammar to be used.
41//!
42//! See [ARCHITECTURE.md](https://github.com/adclz/auto-lsp/blob/main/ARCHITECTURE.md) for more information.
43//!
44//! ## ✨ Features
45//!
46//! - Generates a thread-safe, immutable and iterable AST with parent-child relations from a Tree-sitter language.
47//! - Supports downcasting of AST nodes to concrete types.
48//! - Integrates with a Salsa database and parallelize LSP requests and notifications.
49//!
50//! # 📚 Documentation
51//!
52//! - [book](https://adclz.github.io/auto-lsp/)
53//! - [docs.rs](https://docs.rs/auto-lsp)
54//!
55//! ## Examples
56//!
57//! - [HTML AST](https://github.com/adclz/auto-lsp/tree/main/examples/ast-html)
58//! - [Python AST](https://github.com/adclz/auto-lsp/tree/main/examples/ast-python)
59//! - [Simple LSP Server](https://github.com/adclz/auto-lsp/tree/main/examples/native)
60//! - [Vscode extension](https://github.com/adclz/auto-lsp/tree/main/examples/vscode-native)
61//! - [Vscode extension with WASI](https://github.com/adclz/auto-lsp/tree/main/examples/vscode-wasi)
62//!
63//! # Cargo Features
64//!
65//! - `lsp_server`: Enables the LSP server (uses [`lsp_server`]).
66//! - `wasm`: Enables wasm support (only compatible with `wasi-p1-threads`).
67//!
68//! # Inspirations / Similar projects
69//!
70//! - [Volar](https://volarjs.dev/)
71//! - [Type-sitter](https://github.com/Jakobeha/type-sitter/)
72//! - [Rust Analyzer](https://github.com/rust-lang/rust-analyzer)
73//! - [Ruff](https://github.com/astral-sh/ruff)
74//! - [airblast-dev](https://github.com/airblast-dev)'s [texter](https://github.com/airblast-dev/texter), which saved hours of headache
75
76#[cfg(feature = "default")]
77pub mod default {
78 pub use auto_lsp_default::*;
79}
80
81// LSP server (enabled with the feature `lsp_server`)
82#[cfg(feature = "lsp_server")]
83pub mod server {
84 pub use auto_lsp_server::*;
85}
86
87/// Re-export of the [`auto_lsp_core`] crate
88pub mod core {
89 pub use auto_lsp_core::*;
90}
91
92/// Configuration utilities
93#[doc(hidden)]
94pub mod configure;
95
96pub use anyhow;
97#[cfg(feature = "lsp_server")]
98pub use lsp_server;
99pub use lsp_types;
100pub use salsa;
101pub use texter;
102pub use tree_sitter;