aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src
diff options
context:
space:
mode:
authorDavide Galassi2023-03-08 00:34:31 +0000
committerGitHub2023-03-08 00:34:31 +0000
commitf976c004e2efa4cb583b06827b44fef84bf925f5 (patch)
tree1e2b15c6562556648b4e860d0fc8de135c0b3b61 /helix-term/src
parent0e5a4e55a497c58f68859edb48fd85854403b866 (diff)
Allow LSP server to be stopped (#5964)
Diffstat (limited to 'helix-term/src')
-rw-r--r--helix-term/src/commands/typed.rs38
1 files changed, 38 insertions, 0 deletions
diff --git a/helix-term/src/commands/typed.rs b/helix-term/src/commands/typed.rs
index b0fd18a7..0ddca6df 100644
--- a/helix-term/src/commands/typed.rs
+++ b/helix-term/src/commands/typed.rs
@@ -1354,6 +1354,37 @@ fn lsp_restart(
Ok(())
}
+fn lsp_stop(
+ cx: &mut compositor::Context,
+ _args: &[Cow<str>],
+ event: PromptEvent,
+) -> anyhow::Result<()> {
+ if event != PromptEvent::Validate {
+ return Ok(());
+ }
+
+ let doc = doc!(cx.editor);
+
+ let ls_id = doc
+ .language_server()
+ .map(|ls| ls.id())
+ .context("LSP not running for the current document")?;
+
+ let config = doc
+ .language_config()
+ .context("LSP not defined for the current document")?;
+ cx.editor.language_servers.stop(config);
+
+ for doc in cx.editor.documents_mut() {
+ if doc.language_server().map_or(false, |ls| ls.id() == ls_id) {
+ doc.set_language_server(None);
+ doc.set_diagnostics(Default::default());
+ }
+ }
+
+ Ok(())
+}
+
fn tree_sitter_scopes(
cx: &mut compositor::Context,
_args: &[Cow<str>],
@@ -2350,6 +2381,13 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
completer: None,
},
TypableCommand {
+ name: "lsp-stop",
+ aliases: &[],
+ doc: "Stops the Language Server that is in use by the current doc",
+ fun: lsp_stop,
+ completer: None,
+ },
+ TypableCommand {
name: "tree-sitter-scopes",
aliases: &[],
doc: "Display tree sitter scopes, primarily for theming and development.",