Which-key mapping conflict

Hello, I ran into this issue. I get this message:

There were issues reported with your **which-key** mappings.                                                                                                                            
Use `:checkhealth which-key` to find out more.

and this is in checkhealth:

checking for overlapping keymaps ~
- WARNING In mode `n`, <y> overlaps with <y<C-G>>:
- WARNING In mode `n`, <gc> overlaps with <gcO>, <gcA>, <gcc>, <gco>:
  - <y>: nvim-tree: Copy Name
- WARNING In mode `n`, <gc> overlaps with <gcO>, <gcA>, <gcc>, <gco>:
  - <gc>: Comment toggle linewise
  - <gcO>: Comment insert above
  - <gcA>: Comment insert end of line
  - <gcc>: Comment toggle current line
  - <gco>: Comment insert below
- WARNING In mode `n`, <gb> overlaps with <gbc>:
  - <gb>: Comment toggle blockwise
  - <gbc>: Comment toggle current block

I cannot find where those keys are configured, they aren’t explicitly configured at least. How can I find them or can I override them?

1 Like

Okay, so the issue was more than that actually. There were error messages that I missed. But I resolved key conflict warnings like so:

vim.keymap.del('n', 'gbc')
vim.keymap.del('n', 'gc')
vim.keymap.del('n', 'y<C-G>')

deleting mapping for y doesn’t work.

Other errors were because of deprecated functionality that I hadn’t updated:

-- document existing key chains
require('which-key').register {
  ['<leader>c'] = { name = '[C]ode', _ = 'which_key_ignore' },
  ['<leader>d'] = { name = '[D]ocument', _ = 'which_key_ignore' },
  ['<leader>g'] = { name = '[G]it', _ = 'which_key_ignore' },
  ['<leader>h'] = { name = 'Git [H]unk', _ = 'which_key_ignore' },
  ['<leader>r'] = { name = '[R]ename', _ = 'which_key_ignore' },
  ['<leader>s'] = { name = '[S]earch', _ = 'which_key_ignore' },
  ['<leader>t'] = { name = '[T]oggle', _ = 'which_key_ignore' },
  ['<leader>w'] = { name = '[W]orkspace', _ = 'which_key_ignore' },
}
-- register which-key VISUAL mode
-- required for visual <leader>hs (hunk stage) to work
require('which-key').register({
  ['<leader>'] = { name = 'VISUAL <leader>' },
  ['<leader>h'] = { 'Git [H]unk' },
}, { mode = 'v' })

replaced that with:

-- document existing key chains
require('which-key').add {
  { '<leader>c',  name = '[C]ode' },
  { '<leader>d', name = '[D]ocument' },
  { '<leader>g', name = '[G]it' },
  { '<leader>h', group = 'Git [H]unk', mode = { 'n', 'v' } },
  { '<leader>r', name = '[R]ename' },
  { '<leader>s', name = '[S]earch' },
  { '<leader>t', name = '[T]oggle' },
  { '<leader>w', name = '[W]orkspace' },

  -- register which-key VISUAL mode
  -- required for visual <leader>hs (hunk stage) to work
  { '<leader>', name = 'VISUAL <leader>', mode = { 'v' } },
}
2 Likes