one of the most basic things when navigating code is jumping around, and Neovim with LSP does it perfectly. With a large screen it’s convinient to jump to definitions in a vertical or horizontal split, so the context of the currently open file is not lost.
How can I do this with Neovim?
I tried to:
search documentation (":help lsp" and searching for “split”, “jump” and “definition”) - no luck
search github, found this closed issue, which has no answer except “This can be done with basic vimscript.”.
searched this forum - found only this topic, it discusses alternative file opening in vsplit for clangd
Basically I need to find/guess two commands similar to vim.lsp.buf.definition() that do the same but one is for vertical split and other for horizontal
I believe this should be come as a default commands.
Do you mean that you want to jump to definition in any available split or to open a new split and jump to definition there? In any case, I’m also interested in any of those.
The closest think I can think of is peek preview, but that is not “permanent”.
What I currently do is use go to references, which opens quick fix window and navigate from there
I mean new split. Basically the goal is to temporarily go to another piece of code, without losing context in the current buffer (i.e. keep in sight) – and maybe navigate further into new files in a new splits. I have 49" screen, so it’s common to have 3-5 split screens. In my old setup that was out of the box (I think it was coc) and was super handy.
I also managed to somehow implement this with neovim, but I spend two evenings on that, and can’t find that config anymore
Does it work? if it does, then I think it doesn’t matter how efficient it is?
You can have a look at the trouble plugin, they seem to have some features around easily navigating between definitions.
Also BQF provides preview on the quickfix list, so maybe that is enough to not loose context?