This is a follow up question to this post where I would jump to the definition of a variable in a vertical split for ctags. I’m currently using an lsp language server like so:
local bufopts = { noremap=true, silent=true, buffer=bufnr }
local servers = { 'tsserver', 'eslint', 'bashls','jsonls' }
for _, lsp in ipairs(servers) do
lspconfig[lsp].setup {
..
on_attach = function(client, bufnr)
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts)
end
}
end
How can I set up the keymap so that I can jump to the definition in a vertical split here?
update
What I’m really asking here is how to combine vim commands with this vim.lsp.buf.definition
so by going over the docs and trying to implement one of the answers, I did this
on_attach = function(client, bufnr)
vim.keymap.set('n', 'gv', function()
vsplit vim.lsp.buf.definition
end , bufopts)
but that didn’t work.