1pub mod client;
25pub mod protocol;
26pub mod server;
27pub mod types;
28
29pub use client::{LspClient, SyncLspClient};
30pub use protocol::{
31 create_code_action_request, create_completion_request, create_definition_request,
32 create_did_change_notification, create_did_close_notification, create_did_open_notification,
33 create_document_highlight_request, create_document_symbol_request, create_formatting_request,
34 create_hover_request, create_initialize_request, create_references_request,
35 create_rename_request, create_signature_help_request, create_workspace_symbol_request,
36 LspMessage, LspNotification, LspRequest, LspResponse,
37};
38pub use server::{
39 clangd_config, gopls_config, pylance_config, pyright_config, rust_analyzer_config,
40 typescript_config, LanguageServer, LanguageServerConfig, LanguageServerManager,
41};
42pub use types::*;
43
44#[derive(Debug, thiserror::Error)]
46pub enum LspError {
47 #[error("LSP server not found for language: {0}")]
48 ServerNotFound(String),
49
50 #[error("LSP server initialization failed: {0}")]
51 InitializationFailed(String),
52
53 #[error("LSP request failed: {0}")]
54 RequestFailed(String),
55
56 #[error("LSP timeout")]
57 Timeout,
58
59 #[error("LSP server crashed: {0}")]
60 ServerCrashed(String),
61
62 #[error("Invalid LSP message: {0}")]
63 InvalidMessage(String),
64
65 #[error("IO error: {0}")]
66 Io(#[from] std::io::Error),
67
68 #[error("JSON error: {0}")]
69 Json(#[from] serde_json::Error),
70}
71
72pub type LspResult<T> = std::result::Result<T, LspError>;