pub struct LspCore { /* private fields */ }Expand description
The headless LSP core state machine.
This struct contains all the state and logic for the language server, independent of the platform-specific event loop. Both native and WASM implementations use this core.
Implementations§
Source§impl LspCore
impl LspCore
Sourcepub fn runtime_mut(&mut self) -> &mut QueryRuntime
pub fn runtime_mut(&mut self) -> &mut QueryRuntime
Get a mutable reference to the query runtime.
This is useful for registering workspaces during initialization.
Sourcepub fn is_initialized(&self) -> bool
pub fn is_initialized(&self) -> bool
Check if the server has been initialized.
Sourcepub fn set_initialized(&mut self)
pub fn set_initialized(&mut self)
Mark the server as initialized.
Sourcepub fn pending_files(&self) -> impl Iterator<Item = &TextFile>
pub fn pending_files(&self) -> impl Iterator<Item = &TextFile>
Get pending files that need to be fetched.
Sourcepub fn pending_globs(&self) -> impl Iterator<Item = (&str, &Glob)>
pub fn pending_globs(&self) -> impl Iterator<Item = (&str, &Glob)>
Get pending glob patterns that need to be expanded.
Sourcepub fn open_document(&mut self, uri: &str, content: String)
pub fn open_document(&mut self, uri: &str, content: String)
Open a document and cache its content.
This should be called when a textDocument/didOpen notification is received.
Sourcepub fn change_document(&mut self, uri: &str, content: String)
pub fn change_document(&mut self, uri: &str, content: String)
Update a document’s content.
This should be called when a textDocument/didChange notification is received.
Sourcepub fn close_document(&mut self, uri: &str)
pub fn close_document(&mut self, uri: &str)
Close a document and clear its cached content.
This should be called when a textDocument/didClose notification is received.
Sourcepub fn get_document(&self, uri: &str) -> Option<&String>
pub fn get_document(&self, uri: &str) -> Option<&String>
Get the cached content of a document.
Sourcepub fn handle_request(
&mut self,
id: CoreRequestId,
method: &str,
params: Value,
) -> (Vec<LspOutput>, Vec<Effect>)
pub fn handle_request( &mut self, id: CoreRequestId, method: &str, params: Value, ) -> (Vec<LspOutput>, Vec<Effect>)
Handle an LSP request.
Returns outputs to send to the client and effects for the platform to perform.
Sourcepub fn cancel_request(&mut self, id: &CoreRequestId)
pub fn cancel_request(&mut self, id: &CoreRequestId)
Cancel a pending request.
Sourcepub fn handle_notification(
&mut self,
method: &str,
params: Value,
) -> (Vec<LspOutput>, Vec<Effect>)
pub fn handle_notification( &mut self, method: &str, params: Value, ) -> (Vec<LspOutput>, Vec<Effect>)
Handle an LSP notification.
Returns outputs to send to the client and effects for the platform to perform.