pub struct LspClient { /* private fields */ }Expand description
LSP client over stdio transport (JSON-RPC 2.0).
Implementations§
Source§impl LspClient
impl LspClient
Sourcepub fn start(config: &LspServerConfig, root_dir: &Path) -> Result<Self>
pub fn start(config: &LspServerConfig, root_dir: &Path) -> Result<Self>
Start an LSP server process and perform the initialize handshake.
Sourcepub fn open_file(
&mut self,
rel_path: &str,
content: &str,
language_id: &str,
) -> Result<()>
pub fn open_file( &mut self, rel_path: &str, content: &str, language_id: &str, ) -> Result<()>
Open a file in the language server (required before definition queries).
Sourcepub fn close_file(&mut self, rel_path: &str) -> Result<()>
pub fn close_file(&mut self, rel_path: &str) -> Result<()>
Close a file in the language server.
Sourcepub fn progress_token_summary(&self) -> String
pub fn progress_token_summary(&self) -> String
Wait for the language server to finish indexing the project.
Uses the LSP $/progress notification protocol:
- Server sends
window/workDoneProgress/createto register a progress token - Server sends
$/progresswithkind: "begin"when work starts - Server sends
$/progresswithkind: "report"for updates - Server sends
$/progresswithkind: "end"when work completes
We wait until all active progress tokens have reached “end”.
Fallback: if no progress notifications arrive within initial_wait, we assume
the server either doesn’t support progress or finished instantly.
Get a summary of progress tokens for debugging
pub fn wait_until_ready(&mut self, max_wait: Duration) -> Result<()>
Sourcepub fn get_definition(
&mut self,
rel_path: &str,
line: u32,
character: u32,
) -> Result<Option<LspLocation>>
pub fn get_definition( &mut self, rel_path: &str, line: u32, character: u32, ) -> Result<Option<LspLocation>>
Get definition location for a symbol at the given position. Returns None if no definition found or definition is outside project.
Sourcepub fn get_references(
&mut self,
rel_path: &str,
line: u32,
character: u32,
include_declaration: bool,
) -> Result<Vec<LspLocation>>
pub fn get_references( &mut self, rel_path: &str, line: u32, character: u32, include_declaration: bool, ) -> Result<Vec<LspLocation>>
Find all references to the symbol at the given position.
Returns locations of all call sites / usages within the project.
include_declaration controls whether the definition itself is included.
Sourcepub fn get_implementations(
&mut self,
rel_path: &str,
line: u32,
character: u32,
) -> Result<Vec<LspLocation>>
pub fn get_implementations( &mut self, rel_path: &str, line: u32, character: u32, ) -> Result<Vec<LspLocation>>
Find all implementations of a trait method or interface method at the given position. Returns locations of all concrete implementations within the project.