Skip to content

Commit

Permalink
feat: show a warning if <leader> is already mapped, even if it's <nop>
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Apr 29, 2021
1 parent d07ae74 commit ac56f45
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lua/which-key/keys.lua
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,14 @@ function M.update_keymaps(mode, buf)
local has_secret = keymap.lhs:find(secret)
-- skip auto which-key mappings
local has_wk = keymap.rhs:find("which%-key") and keymap.rhs:find("auto")

-- check if <leader> was remapped
if not has_wk and Util.t(keymap.lhs) == Util.t("<leader>") then
Util.warn(string.format(
"Your <leader> key for %q mode in buf %d is currently mapped to %q. WhichKey automatically creates triggers, so please remove the mapping",
mode, buf or 0, keymap.rhs))
end

if not (has_secret or has_wk) then
local mapping = {
id = Util.t(keymap.lhs),
Expand Down

0 comments on commit ac56f45

Please sign in to comment.