Skip to content

[audit] fix: use "buf" instead of deprecated "buffer" key in keymap opts - #331

Merged
stanfish06 merged 1 commit into
masterfrom
audit/lsp-keymap-buf-key
Sep 21, 2026
Merged

stanfish06 merged 1 commit into
masterfrom
audit/lsp-keymap-buf-key

Conversation

@stanfish06

Copy link
Copy Markdown
Owner

What

runtime/doc/deprecated.txt (deprecated-0.12 section) renames the "buffer" key accepted by vim.keymap.set.Opts / vim.keymap.del.Opts to "buf". lua/config/lsp.lua:8 defines local BUF = "buffer", which is used as the buffer-local option key for the two LspAttach keymaps (gd, <leader>la) at lines 136-137. That's the old, deprecated spelling.

Where

lua/config/lsp.lua:8 (and its two use sites at :136 and :137, unchanged — only the constant's value changes).

Why it matters

Confirmed via runtime/doc/deprecated.txt on neovim/neovim master:

• "buffer" in `vim.keymap.set.Opts` and `vim.keymap.del.Opts`	Renamed to "buf"

This is the only place in the repo using the old key — plugin_config.lua's "buffer" string is an unrelated blink.cmp completion source name, not a keymap opts key (verified via repo-wide grep). Left as-is, this keeps emitting a deprecation warning today and will break once Neovim removes the old key outright, same pattern as the other option/API renames already tracked in #283.

Fix

One-line rename of the BUF constant from "buffer" to "buf". No behavior change — both spellings currently work identically, this just uses the current name.


Generated by Claude Code

vim.keymap.set.Opts renamed "buffer" to "buf" (runtime/doc/deprecated.txt).
lsp.lua's BUF constant still used the old name for the two buffer-local
LspAttach keymaps (gd, <leader>la). No behavior change, just drops the
deprecation warning ahead of it becoming a hard error.
@stanfish06
stanfish06 marked this pull request as ready for review September 21, 2026 01:35

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9382861798

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread lua/config/lsp.lua

local blink_ok = pcall(require, "blink.cmp")
local BUF = "buffer"
local BUF = "buf"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve keymap compatibility with pre-0.12 Neovim

On the pre-0.12 distro installations that this module explicitly supports, vim.keymap.set recognizes only opts.buffer; it forwards the unknown buf option to nvim_set_keymap, which rejects it. Consequently, every LspAttach callback errors before installing the gd and <leader>la mappings or setting formatexpr. Keep buffer until old-version support is dropped, or select the option name based on the Neovim version.

Useful? React with 👍 / 👎.

@stanfish06
stanfish06 merged commit a923a8c into master Sep 21, 2026
4 checks passed
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