Skip to main content

vibelang_lsp/
lib.rs

1//! Language Server Protocol implementation for VibeLang (core2-based).
2//!
3//! This crate provides a full-featured LSP server for VibeLang, built on top of
4//! vibelang-core2 for modern, async validation.
5//!
6//! # Features
7//!
8//! - Syntax error diagnostics (via Rhai compilation)
9//! - Semantic diagnostics (undefined synthdefs, voices, etc.)
10//! - Auto-completion for API functions, synthdefs, and stdlib imports
11//! - Hover documentation for API, UGens, and synthdefs
12//! - Go-to-definition for imports and variables
13//! - Signature help for function parameters
14//! - Document symbols (outline view)
15//! - Code actions (quick fixes)
16//! - Semantic tokens (syntax highlighting)
17//! - Inlay hints (inline annotations)
18//!
19//! # Usage
20//!
21//! ```ignore
22//! use vibelang_lsp::run_lsp_server;
23//!
24//! #[tokio::main]
25//! async fn main() -> anyhow::Result<()> {
26//!     run_lsp_server().await
27//! }
28//! ```
29
30pub mod analysis;
31pub mod data;
32pub mod features;
33pub mod server;
34pub mod utils;
35pub mod validation;
36
37pub use server::VibeLangServer;
38
39use tower_lsp::{LspService, Server};
40
41/// Run the LSP server over stdio.
42///
43/// This function blocks until the client disconnects.
44pub async fn run_lsp_server() -> anyhow::Result<()> {
45    let stdin = tokio::io::stdin();
46    let stdout = tokio::io::stdout();
47
48    let (service, socket) = LspService::new(VibeLangServer::new);
49    Server::new(stdin, stdout, socket).serve(service).await;
50
51    Ok(())
52}