From 4eca4b3079bf53de874959270d0b3471d320debc Mon Sep 17 00:00:00 2001 From: Ole Krüger Date: Tue, 31 Jan 2023 11:38:53 +0100 Subject: Support goto-declaration LSP command (#5646) --- helix-lsp/src/client.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'helix-lsp') 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, + ) -> Option>> { + 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::( + text_document, + position, + work_done_token, + )) + } + pub fn goto_type_definition( &self, text_document: lsp::TextDocumentIdentifier, -- cgit v1.2.3-70-g09d2