Skip to content

[audit] Fix deprecated buffer key in vim.keymap.set opts (Neovim 0.12)#137

Merged
stanfish06 merged 2 commits into
masterfrom
audit/keymap-buf-option
Jun 4, 2026
Merged

[audit] Fix deprecated buffer key in vim.keymap.set opts (Neovim 0.12)#137
stanfish06 merged 2 commits into
masterfrom
audit/keymap-buf-option

Conversation

@stanfish06
Copy link
Copy Markdown
Owner

What

Neovim 0.12 deprecates the buffer option key in vim.keymap.set() / vim.keymap.del() in favour of buf.

Where

lua/config/plugin_config.lua:112 — inside the LspAttach autocmd callback:

-- before
local opts = { buffer = ev.buf }

-- after
local opts = { buf = ev.buf }

Why it matters

The config targets Neovim 0.12+ (uses vim.pack, vim.lsp.config, vim.lsp.enable, completeopt = "fuzzy", winborder, all 0.11/0.12 APIs). Using the deprecated buffer key will produce a deprecation warning in 0.12 and will stop working in a future release once the key is removed.

Change

One-line rename: buffer = ev.bufbuf = ev.buf in the opts table passed to vim.keymap.set("n", "gd", ...).

References

  • Neovim 0.12 release notes: :help news-0.12 → vim.keymap section
  • deprecated.txt: vim.keymap.set()/del() buffer option → buf

Generated by Claude Code

Neovim 0.12 deprecates the `buffer` option key in `vim.keymap.set()` /
`vim.keymap.del()` in favour of `buf`. The LspAttach callback in
plugin_config.lua was using the old form `{ buffer = ev.buf }`.

https://claude.ai/code/session_01PJNb6QtQTFur5vCNVVccfX
@stanfish06
Copy link
Copy Markdown
Owner Author

@claude , make it backward compatible, not all of my machines are on v12

@claude
Copy link
Copy Markdown

claude Bot commented Jun 4, 2026

Claude finished @stanfish06's task in 52s —— View job


Backward-compatible buf/buffer key

  • Gather context — read lua/config/plugin_config.lua:112
  • Understand request — make buf/buffer key work on both <0.12 and 0.12+
  • Implement backward-compatible version check
  • Commit and push

Change applied (lua/config/plugin_config.lua:112):

-- before
local opts = { buf = ev.buf }

-- after
local opts = vim.fn.has('nvim-0.12') == 1 and { buf = ev.buf } or { buffer = ev.buf }

vim.fn.has('nvim-0.12') returns 1 on Neovim 0.12+ and 0 on older versions, so buf is used where it's expected and buffer is used as the fallback on older installs.
·

Use buf on 0.12+ (where buffer is deprecated) and fall back to
buffer on older Neovim versions.

Co-authored-by: Zhiyuan <stanfish06@users.noreply.github.com>
@stanfish06 stanfish06 merged commit d371d58 into master Jun 4, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants