aboutsummaryrefslogtreecommitdiff
path: root/helix-lsp/src
diff options
context:
space:
mode:
authorOle Krüger2023-01-31 10:38:53 +0000
committerGitHub2023-01-31 10:38:53 +0000
commit4eca4b3079bf53de874959270d0b3471d320debc (patch)
tree685da9a2ef16df7b0c135a636f2324e5a2248802 /helix-lsp/src
parentc9b583ea9b59aa78c12e3831ed9c73f83d1d35d8 (diff)
Support goto-declaration LSP command (#5646)
Diffstat (limited to 'helix-lsp/src')
-rw-r--r--helix-lsp/src/client.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/helix-lsp/src/client.rs b/helix-lsp/src/client.rs
index dd2581c6..6827f568 100644
--- a/helix-lsp/src/client.rs
+++ b/helix-lsp/src/client.rs
@@ -886,6 +886,31 @@ impl Client {
))
}
+ pub fn goto_declaration(
+ &self,
+ text_document: lsp::TextDocumentIdentifier,
+ position: lsp::Position,
+ work_done_token: Option<lsp::ProgressToken>,
+ ) -> Option<impl Future<Output = Result<Value>>> {
+ let capabilities = self.capabilities.get().unwrap();
+
+ // Return early if the server does not support goto-declaration.
+ match capabilities.declaration_provider {
+ Some(
+ lsp::DeclarationCapability::Simple(true)
+ | lsp::DeclarationCapability::RegistrationOptions(_)
+ | lsp::DeclarationCapability::Options(_),
+ ) => (),
+ _ => return None,
+ }
+
+ Some(self.goto_request::<lsp::request::GotoDeclaration>(
+ text_document,
+ position,
+ work_done_token,
+ ))
+ }
+
pub fn goto_type_definition(
&self,
text_document: lsp::TextDocumentIdentifier,