Skip to content

Setting up Go to definition? #205

Answered by mrcjkb
MarcCoquand asked this question in Q&A
Jun 21, 2023 · 1 comments · 4 replies
Discussion options

You must be logged in to vote

Hey,

if you want to map gd to go-to-definition, you can add a keymap:

opts = { noremap = true, silent = true, buffer = bufnr } -- bufnr is an argument of the on_attach function
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts)

I don't include all LSP-related keymaps in the readme, because there are already a bunch of suggestions in the nvim-lspconfig readme (which I link to).

For go-to-definition specifically, neovim automatically sets up a tagfunc, so you can use C-[ to jump to a definition, and fall back to tags if the definition can't be found. This is useful if you also use something like fast-tags.

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@MarcCoquand
Comment options

@mrcjkb
Comment options

@MarcCoquand
Comment options

@mrcjkb
Comment options

Answer selected by MarcCoquand
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants