Skip to content

fix: normalize keymap keys before merging user config - #724

Closed
barrettruth wants to merge 1 commit into
stevearc:masterfrom
barrettruth:fix/keymap-normalization
Closed

barrettruth wants to merge 1 commit into
stevearc:masterfrom
barrettruth:fix/keymap-normalization

Conversation

@barrettruth

Copy link
Copy Markdown

Problem

Keymap overrides using non-canonical casing (e.g. <c-t> instead of <C-t>) fail to replace the corresponding default keymap. The keys are compared as raw strings during the merge in config.setup(), so both the user entry and the default entry remain in the table. Depending on pairs() iteration order, the default may overwrite the user's override when applied via vim.keymap.set.

Solution

Normalize keymap keys with vim.api.nvim_replace_termcodes during the merge loop. Before inserting each user keymap, any existing default key that normalizes to the same internal representation is removed, ensuring the user's entry is the only one that survives.

Closes #692

@github-actions
github-actions Bot requested a review from stevearc February 15, 2026 06:15
Problem: user keymap overrides like <c-t> failed to replace the
default <C-t> because the keys were compared as raw strings during
merge, leaving both entries in the table.

Solution: use nvim_replace_termcodes to compare keymap keys by their
internal representation, removing any default entry that normalizes
to the same key as the user-provided one before inserting it.
@barrettruth barrettruth closed this by deleting the head repository Feb 18, 2026
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