by berkes · 2y ago · 0 comments
> As an aside, I also use this technique for navigating code with Vim, where a single shortcut goes to a definition of a function in a new pane
I was intrigued by this, and searched the author's github for their .vim. This is how they do that:
nnoremap gF <c-w>vgF
https://github.com/szymonkaliski/dotfiles/blob/357fc7c76ca86...
and
nnoremap <silent>gD :call CocActionAsync('jumpDefinition', 'vsplit')<cr>
https://github.com/szymonkaliski/dotfiles/blob/357fc7c76ca86...
---
Edit: This is what I ended up with, lua, nvim: `buf_set_keymap('n', 'gds', '<c-w>v<cmd>lua vim.lsp.buf.definition()<CR>', opts)`
I made it a different map from the normal gd, so that I can choose to open in a new split or just jump to the one in my current window - I don't want a new split if e.g. a variable is define just 20 lines above my current one.
I presume one can tweak that delay even. But personally, I'll make all the shortcuts "symmetric", eventually. Indeed "gs" or "gv". In other cases, It'd become "gds", "gdd" or such. But "eventually", I try to change stuff more permanently once I see how I actually use it over a few days or weeks.