lsp: Support Goto Declaration (#15785)
Adds support for [Goto Declaration](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_declaration) LSP command. I am particularly interested in [this for Rust projects](https://rust-analyzer.github.io/manual.html#go-to-declaration), to be able to navigate to the place where a trait method is declared, coming from a trait method implementation. I noticed this was something I could do in VSCode before, but was somehow missing is Zed. Thanks to the already existing infrastructure for Goto Definition, I just followed and copy-paste-adapted it for Goto Declaration. As a bonus, I added `ctrl-F12` and `alt-ctrl-F12` as default macOS keybindings for `GoToDeclaration` and `GoToDeclarationSplit`, respectively. They are not keybindings from another editor, but I figured they made sense to be grouped along with the other *F12 commands. ### Release Notes: - Added "Go to declaration" editor action. - vim: Breaking change to keybindings after introduction of the `Go to declaration` editor action. The new keybindings are the following (and can be found [here](https://zed.dev/docs/vim), alongside the other key bindings): - `g d` - Go to definition - `g D` - Go to declaration - `g y` - Go to type definition - `g I` - Go to implementation https://github.com/user-attachments/assets/ee5c10a8-94f0-4e50-afbb-6f71db540c1b --------- Co-authored-by: Thorsten Ball <mrnugget@gmail.com>
This commit is contained in:
parent
82db5dedfb
commit
7b5fdcee7f
13 changed files with 188 additions and 6 deletions
|
@ -48,6 +48,8 @@ message Envelope {
|
|||
|
||||
GetDefinition get_definition = 32;
|
||||
GetDefinitionResponse get_definition_response = 33;
|
||||
GetDeclaration get_declaration = 237;
|
||||
GetDeclarationResponse get_declaration_response = 238; // current max
|
||||
GetTypeDefinition get_type_definition = 34;
|
||||
GetTypeDefinitionResponse get_type_definition_response = 35;
|
||||
|
||||
|
@ -696,12 +698,23 @@ message GetDefinition {
|
|||
uint64 buffer_id = 2;
|
||||
Anchor position = 3;
|
||||
repeated VectorClockEntry version = 4;
|
||||
}
|
||||
}
|
||||
|
||||
message GetDefinitionResponse {
|
||||
repeated LocationLink links = 1;
|
||||
}
|
||||
|
||||
message GetDeclaration {
|
||||
uint64 project_id = 1;
|
||||
uint64 buffer_id = 2;
|
||||
Anchor position = 3;
|
||||
repeated VectorClockEntry version = 4;
|
||||
}
|
||||
|
||||
message GetDeclarationResponse {
|
||||
repeated LocationLink links = 1;
|
||||
}
|
||||
|
||||
message GetTypeDefinition {
|
||||
uint64 project_id = 1;
|
||||
uint64 buffer_id = 2;
|
||||
|
|
|
@ -239,6 +239,8 @@ messages!(
|
|||
(GetCompletionsResponse, Background),
|
||||
(GetDefinition, Background),
|
||||
(GetDefinitionResponse, Background),
|
||||
(GetDeclaration, Background),
|
||||
(GetDeclarationResponse, Background),
|
||||
(GetDocumentHighlights, Background),
|
||||
(GetDocumentHighlightsResponse, Background),
|
||||
(GetHover, Background),
|
||||
|
@ -437,6 +439,7 @@ request_messages!(
|
|||
(GetCodeActions, GetCodeActionsResponse),
|
||||
(GetCompletions, GetCompletionsResponse),
|
||||
(GetDefinition, GetDefinitionResponse),
|
||||
(GetDeclaration, GetDeclarationResponse),
|
||||
(GetImplementation, GetImplementationResponse),
|
||||
(GetDocumentHighlights, GetDocumentHighlightsResponse),
|
||||
(GetHover, GetHoverResponse),
|
||||
|
@ -551,6 +554,7 @@ entity_messages!(
|
|||
GetCodeActions,
|
||||
GetCompletions,
|
||||
GetDefinition,
|
||||
GetDeclaration,
|
||||
GetImplementation,
|
||||
GetDocumentHighlights,
|
||||
GetHover,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue