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:
co-authored by
Thorsten Ball
parent
82db5dedfb
commit
7b5fdcee7f
@@ -218,6 +218,8 @@ See the [tasks documentation](/docs/tasks#custom-keybindings-for-tasks) for more
|
||||
| Format | Editor | `⌘ + Shift + I` |
|
||||
| Go to definition | Editor | `F12` |
|
||||
| Go to definition split | Editor | `Alt + F12` |
|
||||
| Go to declaration | Editor | `Ctrl + F12` |
|
||||
| Go to declaration split | Editor | `Alt + Ctrl + F12` |
|
||||
| Go to diagnostic | Editor | `F8` |
|
||||
| Go to implementation | Editor | `Shift + F12` |
|
||||
| Go to prev diagnostic | Editor | `Shift + F8` |
|
||||
|
||||
+4
-2
@@ -17,8 +17,10 @@ Vim mode has several "core Zed" key bindings, that will help you make the most o
|
||||
```
|
||||
# Language server
|
||||
g d Go to definition
|
||||
g D Go to type definition
|
||||
g cmd-d Go to implementation
|
||||
g D Go to declaration
|
||||
g y Go to type definition
|
||||
g I Go to implementation
|
||||
|
||||
c d Rename (change definition)
|
||||
g A Go to All references to the current word
|
||||
|
||||
|
||||
Reference in New Issue
Block a user