Vim Mode: use `gd` to jump to caller
Check for existing issues
- [X] Completed
Describe the feature
Hey!
Thanks for the project. I have almost switched to Zed for some of my workflow (Go + Rust). I have a small feature request is that:
If I do gd on function name, it should opencaller of the function, if there is only one caller of the function.
If there are more than one caller of that function, then it can open Find All Occurrences, even though we already have gA for that.
This feels very fast way to navigate. I am not sure if there is already a key-binding for such action.
Attaching a screencast (VSCode + Vim Plugin):
https://github.com/zed-industries/zed/assets/48919542/7d9e7bb4-83e8-41d5-a9bb-58275ee36ec2
Similarly, it can/may also work with struct / class / variable
Thanks again.
If applicable, add mockups / screenshots to help present your vision of the feature
No response
We already have a PR for that (except the Vim binding): https://github.com/zed-industries/zed/pull/6924 But it seems a bit stale.
Didn't see that, closing then. Thanks.
That PR is not related to VIM mode, so re-opening this one. But I think that should also solve this one. Keeping this open, so that we can validate with Vim mode and close later, if that makes sense.
Yeah, I think the scope for this one would be to add a vim keybinding if that's not done in the original PR.
Never heard of that use of gd before, I've always used ^o to jump back to my previous location(s). (in Neovim)
@jansol sorry, the title was slightly misleading. It's about opening the caller of the function/class/variable.
@hamza72x gd isn't for going to caller if I'm not mistaken, stands for Go To Definition, then gD stands for Go To Declaration.
This is at least how neovim lsp keymappings work:
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts)
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts)
Reference: https://github.com/neovim/nvim-lspconfig
@vricop I was referring to VSCode+Vim Extension's default behaviour.
@vricop I was referring to VSCode+Vim Extension's default behaviour.
@hamza72x That’s weird the VSCode-neovim plugin does the same neovim does. Maybe it’s a vanilla vim thing. It doesn’t make sense to me imho thought.
Tested with latest Zed Preview, working with custom keybindings.
By default it's mapped to gA -> Reference
[
{
"context": "Editor && vim_mode == normal && !VimWaiting && !menu",
"bindings": {
"g d": "editor::FindAllReferences"
}
}
]
And ofc, Thanks everyone who worked on this. 💐💐