which-key.nvim icon indicating copy to clipboard operation
which-key.nvim copied to clipboard

which-key hijacks my `h` key

Open zeitchef opened this issue 3 years ago • 4 comments

For some reason, I'm not able to use my h key in normal mode any longer. On further investigation, I ran :map and noticed that which-key has remapped it to:

n  h           * <Cmd>lua require("which-key").show("h", {mode = "n", auto = true})<CR>

Any particular reason for this? And can I have my h key back, please?

zeitchef avatar Aug 26 '21 19:08 zeitchef

Ah, I may have solved this myself. I've added h to the triggers_blacklist in normal mode. That seems to have cleared up the issue.

zeitchef avatar Aug 26 '21 20:08 zeitchef

The only reason I can think of, is that you have a mapping under h? So a mapping that starts with h

folke avatar Aug 30 '21 12:08 folke

Indeed, I do. I set up all my mappings like this. In this case, as all my h mappings live under this h scope, I should have foreseen this issue. The blacklist approach above works well enough for my needs.

-- Hop
wk.register({
  h = {
    name = 'Hop',
    l = { ':HopLine<CR>', 'Jump to visible line' },
    p = { ':HopPattern<CR>', 'Jump to pattern' },
    w = { ':HopWord<CR>', 'Jump to word' },
  }
}, { mode = 'n', prefix = '<leader>' })

zeitchef avatar Aug 30 '21 12:08 zeitchef

Similar behavior happens in another very real-life config when using 'vim-sandwich'-like functionality (mapped to sa, sd, etc.) and having nnoremap s <Nop>. So with the example config hitting s;will act as default substitute command instead of acting as;. Without 'which-key' everything works as expected (saandsdwork from maps,sworks as`).

Example config:

lua require('which-key').setup({})
nnoremap s <Nop>
nnoremap sa :echo 'Add'<CR>
nnoremap sd :echo 'Delete'<CR>

Putting n = {'s'} to triggers_blacklist works but leads to not displaying possible options sa and sd.

echasnovski avatar Sep 13 '21 09:09 echasnovski

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Jul 07 '24 01:07 github-actions[bot]