Comment

Comment by berkes

Slightly unrelated:

> 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.

parent berkes 2 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton