|
|
|
@ -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>],
|
|
|
|
@ -2349,6 +2380,13 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
|
|
|
|
|
fun: lsp_restart,
|
|
|
|
|
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: &[],
|
|
|
|
|