1pub mod client;
7pub mod manager;
8pub mod config;
9pub mod types;
10
11pub use client::LspClient;
12pub use manager::LspManager;
13pub use config::{LspConfig, LspServerConfig};
14pub use types::{
15 LspError, LspDiagnostic, DiagnosticSeverity, Position, Range, Location,
16 CompletionItem, CompletionItemKind, Hover, CodeAction, SymbolInformation, SymbolKind
17};
18
19use std::path::Path;
20use async_trait::async_trait;
21
22#[async_trait]
24pub trait LspService: Send + Sync {
25 async fn get_diagnostics(&self, file_path: &Path) -> Result<Vec<LspDiagnostic>, LspError>;
27
28 async fn did_change_file(&self, file_path: &Path, content: &str) -> Result<(), LspError>;
30
31 async fn did_open_file(&self, file_path: &Path, content: &str) -> Result<(), LspError>;
33
34 async fn did_close_file(&self, file_path: &Path) -> Result<(), LspError>;
36
37 fn supports_file(&self, file_path: &Path) -> bool;
39
40 async fn get_completions(&self, file_path: &Path, position: Position) -> Result<Vec<CompletionItem>, LspError>;
42
43 async fn goto_definition(&self, file_path: &Path, position: Position) -> Result<Vec<Location>, LspError>;
45
46 async fn get_hover(&self, file_path: &Path, position: Position) -> Result<Option<Hover>, LspError>;
48
49 async fn find_references(&self, file_path: &Path, position: Position, include_declaration: bool) -> Result<Vec<Location>, LspError>;
51
52 async fn get_code_actions(&self, file_path: &Path, range: Range) -> Result<Vec<CodeAction>, LspError>;
54
55 async fn get_document_symbols(&self, file_path: &Path) -> Result<Vec<SymbolInformation>, LspError>;
57
58 async fn format_document(&self, file_path: &Path) -> Result<String, LspError>;
60
61 async fn format_range(&self, file_path: &Path, range: Range) -> Result<String, LspError>;
63}