folke / which-key.nvim

💥 Create key bindings that stick. WhichKey is a lua plugin for Neovim 0.5 that displays a popup with possible keybindings of the command you started typing.
Apache License 2.0
4.73k stars 154 forks source link

bug: Popup does not appear for j and k #468

Open tim-harding opened 1 year ago

tim-harding commented 1 year ago

Did you check docs and existing issues?

Neovim version (nvim -v)

0.9.1

Operating system/version

Arch Linux

Describe the bug

I have bound the hjkl keys for different purposes. While which-key correctly displays the popup for h and l, it does not do so for j and k. I assume this may be related to the triggers_blacklist setting, so I added the following to my config:

{
  triggers_blacklist = {
    n = {},
    i = {},
    v = {},
  }
}

This does not seem to have an effect. I assume this may be because this setting is merged with the default rather than overwriting it.

Steps To Reproduce

  1. Set the config to

    {
    'folke/which-key.nvim',
    event = 'VeryLazy',
    opts = {
    triggers_blacklist = {
      n = {},
      i = {},
      v = {},
    }
    },
    }
  2. Add some example j and k keybindings and disable the default motions:

    vim.keymap.set('n', 'jj', function() print('Hello from j') end, { desc = 'Say hello from j' })
    vim.keymap.set('n', 'kk', function() print('Hello from k') end, { desc = 'Say hello from k' })
    vim.keymap.set('n', 'j', '<nop>')
    vim.keymap.set('n', 'k', '<nop>')
  3. Press j or k and see that the which-key does not appear.

Expected Behavior

The which-key window appears when pressing j or k.

Repro

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  {
    "folke/which-key.nvim",
    opts = {
      triggers_blacklist = {
        n = {},
        i = {},
        v = {},
      }
    }
  },
}

require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")

-- Add keymaps
vim.keymap.set('n', 'jj', function() print('Hello from j') end, { desc = 'Say hello from j' })
vim.keymap.set('n', 'kk', function() print('Hello from k') end, { desc = 'Say hello from k' })
vim.keymap.set('n', 'j', '<nop>')
vim.keymap.set('n', 'k', '<nop>')
github-actions[bot] commented 4 days ago

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.