use crate::app_state::Screen;
use crate::commands::{CommandRegistry, command};
use crate::operation::Operation;
pub fn register_lsp(registry: &mut CommandRegistry) {
registry.register(
command("lsp.trigger_completion")
.title("Trigger Completion")
.description("Request completions from the LSP server at the current cursor position")
.context("editor")
.hidden()
.handler(|app, _| {
if let Screen::Editor(ed) = &app.screen {
vec![Operation::LspTriggerCompletion {
path: ed.buffer.path.clone(),
trigger_char: None,
}]
} else {
vec![]
}
}),
);
registry.register(
command("lsp.trigger_hover")
.title("Show Hover Info")
.description("Show type signature and documentation for the symbol under the cursor")
.context("editor")
.hidden()
.handler(|app, _| {
if let Screen::Editor(ed) = &app.screen {
vec![Operation::LspTriggerHover {
path: ed.buffer.path.clone(),
idle_generation: None,
}]
} else {
vec![]
}
}),
);
registry.register(
command("lsp.go_to_definition")
.title("Go to Definition")
.description("Jump to the definition of the symbol under the cursor")
.context("editor")
.hidden()
.handler(|app, _| {
if let Screen::Editor(ed) = &app.screen {
vec![Operation::LspGoToDefinition {
path: ed.buffer.path.clone(),
}]
} else {
vec![]
}
}),
);
registry.register(
command("lsp.rename")
.title("Rename Symbol")
.description("Rename the symbol under the cursor across all files in the project")
.context("editor")
.hidden()
.handler(|app, _| {
if let Screen::Editor(ed) = &app.screen {
vec![Operation::LspTriggerRename {
path: ed.buffer.path.clone(),
}]
} else {
vec![]
}
}),
);
}