aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/commands
diff options
context:
space:
mode:
Diffstat (limited to 'helix-term/src/commands')
-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.",