[audit] fix LspAttach gd keymap: remove invalid buf key, use buffer for all nvim versions#150
Merged
Merged
Conversation
On nvim-0.12+, the version check used { buf = ev.buf } which is not a
valid key for vim.keymap.set; the recognised option is `buffer`. This
made gd a global map on 0.12+ instead of buffer-local. The condition was
also logically reversed (new version got the wrong key, old got correct).
Simplify to { buffer = ev.buf } which is valid on all supported versions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
lua/config/plugin_config.lua:115had a version-guarded opts table for thegdbuffer-local keymap that contained a bug on two levels:Problem 1 — invalid key
buf:vim.keymap.setacceptsbufferfor a buffer-local keymap, notbuf. Passing{ buf = ev.buf }is silently ignored, so on nvim-0.12+gdwas registered as a global map rather than buffer-local — it would apply in every buffer regardless of which LSP was attached.Problem 2 — inverted condition: the branch that returned the wrong key (
buf) was guarded byhas('nvim-0.12') == 1, i.e. the newest code path was also the broken one.Where
lua/config/plugin_config.lua, lines 115–116 (inside theLspAttachautocmd callback).Fix
bufferis the correct, documented key for buffer-local keymaps invim.keymap.setand has been so since Neovim 0.7. The version check is unnecessary and removed.Risk
Low — this restores the intended behaviour (buffer-local
gd). The only visible change is thatgdno longer leaks into buffers that have no LSP attached.Generated by Claude Code