pub mod clangd;
pub mod client;
pub mod extract;
pub mod fortls;
pub mod gopls;
pub mod jdtls;
pub mod pyright;
pub(crate) mod references_cache;
pub(crate) mod session;
pub mod types;
pub mod typescript_ls;
pub use clangd::ClangdClient;
pub use client::RustAnalyzerClient;
pub use extract::extract_hover_text;
pub use fortls::FortlsClient;
pub use gopls::GoplsClient;
pub use jdtls::JdtlsClient;
pub use pyright::PyrightClient;
pub use references_cache::{CacheKey, Clock, MockClock, ReferencesCache, SystemClock};
pub use types::map_lsp_symbol_kind;
pub use typescript_ls::TypeScriptLanguageClient;
use std::path::Path;
#[derive(Debug, thiserror::Error)]
pub enum LspError {
#[error("failed to start LSP server: {0}")]
ServerStart(String),
#[error("LSP communication error: {0}")]
Communication(String),
#[error("LSP request timed out after {0} ms")]
Timeout(u64),
#[error("LSP method not implemented: {0}")]
NotImplemented(String),
}
pub const REQUEST_TIMEOUT_MS: u64 = 5_000;
pub trait LspProvider: Send + Sync {
fn start(&self, workspace: &Path) -> Result<(), LspError>;
fn definition(
&self,
file: &Path,
line: u32,
col: u32,
) -> Result<Option<lsp_types::Location>, LspError>;
fn type_definition(
&self,
file: &Path,
line: u32,
col: u32,
) -> Result<Option<lsp_types::Location>, LspError>;
fn hover(&self, file: &Path, line: u32, col: u32)
-> Result<Option<lsp_types::Hover>, LspError>;
fn references(
&self,
file: &Path,
line: u32,
col: u32,
) -> Result<Vec<lsp_types::Location>, LspError> {
let _ = (file, line, col);
Err(LspError::NotImplemented(format!(
"{}: textDocument/references not implemented",
std::any::type_name::<Self>()
)))
}
fn shutdown(&self) -> Result<(), LspError>;
}