diff options
author | Ryan Fowler | 2023-07-21 22:21:21 +0000 |
---|---|---|
committer | GitHub | 2023-07-21 22:21:21 +0000 |
commit | 5c41f22c2a20a1b8a91ddd6397686bd752591ffc (patch) | |
tree | f64c0dba72fb6b14a7c0f0f4c98220a25f5b2462 /helix-lsp/src/lib.rs | |
parent | 8977123f25baba838d2d16f8a40e78563c4ebf4a (diff) |
Add support for LSP DidChangeWatchedFiles (#7665)
* Add initial support for LSP DidChangeWatchedFiles
* Move file event Handler to helix-lsp
* Simplify file event handling
* Refactor file event handling
* Block on future within LSP file event handler
* Fully qualify uses of the file_event::Handler type
* Rename ops field to options
* Revert newline removal from helix-view/Cargo.toml
* Ensure file event Handler is cleaned up when lsp client is shutdown
Diffstat (limited to 'helix-lsp/src/lib.rs')
-rw-r--r-- | helix-lsp/src/lib.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/helix-lsp/src/lib.rs b/helix-lsp/src/lib.rs index 95c61086..90f0c3fd 100644 --- a/helix-lsp/src/lib.rs +++ b/helix-lsp/src/lib.rs @@ -1,4 +1,5 @@ mod client; +pub mod file_event; pub mod jsonrpc; pub mod snippet; mod transport; @@ -547,6 +548,7 @@ pub enum MethodCall { WorkspaceFolders, WorkspaceConfiguration(lsp::ConfigurationParams), RegisterCapability(lsp::RegistrationParams), + UnregisterCapability(lsp::UnregistrationParams), } impl MethodCall { @@ -570,6 +572,10 @@ impl MethodCall { let params: lsp::RegistrationParams = params.parse()?; Self::RegisterCapability(params) } + lsp::request::UnregisterCapability::METHOD => { + let params: lsp::UnregistrationParams = params.parse()?; + Self::UnregisterCapability(params) + } _ => { return Err(Error::Unhandled); } @@ -629,6 +635,7 @@ pub struct Registry { syn_loader: Arc<helix_core::syntax::Loader>, counter: usize, pub incoming: SelectAll<UnboundedReceiverStream<(usize, Call)>>, + pub file_event_handler: file_event::Handler, } impl Registry { @@ -638,6 +645,7 @@ impl Registry { syn_loader, counter: 0, incoming: SelectAll::new(), + file_event_handler: file_event::Handler::new(), } } @@ -650,6 +658,7 @@ impl Registry { } pub fn remove_by_id(&mut self, id: usize) { + self.file_event_handler.remove_client(id); self.inner.retain(|_, language_servers| { language_servers.retain(|ls| id != ls.id()); !language_servers.is_empty() @@ -715,6 +724,7 @@ impl Registry { .unwrap(); for old_client in old_clients { + self.file_event_handler.remove_client(old_client.id()); tokio::spawn(async move { let _ = old_client.force_shutdown().await; }); @@ -731,6 +741,7 @@ impl Registry { pub fn stop(&mut self, name: &str) { if let Some(clients) = self.inner.remove(name) { for client in clients { + self.file_event_handler.remove_client(client.id()); tokio::spawn(async move { let _ = client.force_shutdown().await; }); |