New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Defaults: map gd to CTRL-] #28476
Comments
We could also do Example keymapvim.keymap.set('n', 'gd', function()
if vim.o.tagfunc ~= '' or #vim.fn.tagfiles() > 0 then
return '<C-]>'
end
return 'gd'
end, { expr = true }) Or we also could do that if |
Note that we currently also have the unmapped:
all of which also fit into the |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
In help pages |
The original justification for this suggestion was that it was awkward or difficult to use |
I am using corne keyboard and it is somewhat inconvenient indeed. |
The context is that is that This is completely incorrect. It turns out This phenomenon is not isolated to |
Seems worth mentioning at |
The default mapping for "jump to tag" is
<C-]>
, but this is awkward or difficult to type on some keyboards.Nvim's LSP client sets
tagfunc
by default which enables jumping to a definition with<C-]>
.gd
is a very popular custom mapping for jumping to a definition, so mappinggd
to<C-]>
would essentially provide that mapping for free.We could either do this universally, or only when an LSP buffer is attached. One downside of doing it universally is that if an LSP buffer is not attached, and there are no valid tags files, then we lose the builtin
gd
behavior (which is, frankly, not very good, but some people may rely on it).Note that we do not simply map
gd
tovim.lsp.buf.definition()
by default because using'tagfunc'
provides a lot of other useful functionality (opening a definition in a split, searching for identifiers with:ts
, etc.).EDIT: This is really only useful if mapping
gd
to<C-]>
also gets us<C-W>gd
"for free", which I'm not sure if it does.The text was updated successfully, but these errors were encountered: