Skip to content

fix: let user keymaps override defaults written with different casing - #794

Open
dinhkarate wants to merge 1 commit into
stevearc:masterfrom
dinhkarate:fix/692-normalize-keymap-keys
Open

dinhkarate wants to merge 1 commit into
stevearc:masterfrom
dinhkarate:fix/692-normalize-keymap-keys

Conversation

@dinhkarate

Copy link
Copy Markdown

Fixes #692

A user keymap written with different casing than the default, e.g. ["<c-t>"] = false, did not replace the default ["<C-t>"]. setup() merges keymaps by raw string, so both entries ended up in config.keymaps and the default was still mapped (or the two fought over the key, depending on pairs() order).

When merging, the user's key and each default key are now compared after nvim_replace_termcodes, and a default that is the same key is dropped. Defaults the user set explicitly themselves are left alone, and use_default_keymaps = false is unchanged.

Tests: new tests/config_spec.lua sets <c-t> = false and <c-S> to another action, opens oil and checks with maparg that <C-t> is unmapped, <C-s> runs the user's action and <CR> still has its default. It fails without the change. ./run_tests.sh: 109 passed, 0 failed (Neovim 0.12.6). luacheck lua tests and stylua --check are clean.

A user keymap such as <c-t> did not replace the default <C-t>: both entries stayed in the keymaps table, so <c-t> = false left the default mapped. Compare keys with nvim_replace_termcodes and drop any default that is the same key as one the user set.

Fixes stevearc#692
@github-actions
github-actions Bot requested a review from stevearc November 2, 2026 20:35
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.

bug: keymap configuration not normalized

1 participant