diff options
author | wojciechkepka | 2021-06-19 02:56:50 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2021-06-19 04:02:56 +0000 |
commit | c2aad859b12e01c7724f16ddf957e6db2b3c8a60 (patch) | |
tree | 5849e5130cf8249d45ade382128233bb32c07f65 /helix-lsp/src | |
parent | 03d1ca7b0a2610b5a5ee2956722c0a1fbdc2180c (diff) |
Handle language server shutdown with timeout
Diffstat (limited to 'helix-lsp/src')
-rw-r--r-- | helix-lsp/src/client.rs | 15 | ||||
-rw-r--r-- | helix-lsp/src/lib.rs | 4 |
2 files changed, 19 insertions, 0 deletions
diff --git a/helix-lsp/src/client.rs b/helix-lsp/src/client.rs index 245eb854..101d2f9b 100644 --- a/helix-lsp/src/client.rs +++ b/helix-lsp/src/client.rs @@ -272,6 +272,21 @@ impl Client { self.notify::<lsp::notification::Exit>(()) } + /// Tries to shut down the language server but returns + /// early if server responds with an error. + pub async fn shutdown_and_exit(&self) -> Result<()> { + self.shutdown().await?; + self.exit().await + } + + /// Forcefully shuts down the language server ignoring any errors. + pub async fn force_shutdown(&self) -> Result<()> { + if let Err(e) = self.shutdown().await { + log::warn!("language server failed to terminate gracefully - {}", e); + } + self.exit().await + } + // ------------------------------------------------------------------------------------------- // Text document // ------------------------------------------------------------------------------------------- diff --git a/helix-lsp/src/lib.rs b/helix-lsp/src/lib.rs index 774de075..49d5527f 100644 --- a/helix-lsp/src/lib.rs +++ b/helix-lsp/src/lib.rs @@ -310,6 +310,10 @@ impl Registry { Err(Error::LspNotDefined) } } + + pub fn iter_clients(&self) -> impl Iterator<Item = &Arc<Client>> { + self.inner.values().map(|(_, client)| client) + } } #[derive(Debug)] |