folke / which-key.nvim

💥 Create key bindings that stick. WhichKey helps you remember your Neovim keymaps, by showing available keybindings in a popup as you type.
Apache License 2.0
5.12k stars 163 forks source link

bug: #781

Closed kyerpotts closed 1 month ago

kyerpotts commented 1 month ago

Did you check docs and existing issues?

Neovim version (nvim -v)

0.10.0 release

Operating system/version

Arch Linux

Describe the bug

Which-key works fine with my leader key () until I open Neo-tree, after which space no longer triggers which key. I believe Neo-tree may have a local mapping to space for toggling nodes, which may be part of the issue. This was never a problem until the latest update

Steps To Reproduce

  1. Toggle Neotree on
  2. Toggle Neotree off
  3. Press space () and which-key is no longer triggered

Expected Behavior

Which-key should be triggered by the leader () key regardless of local mappings by other plugins

Health

==============================================================================
which-key: require("which-key.health").check()

- OK Most of these checks are for informational purposes only.
  WARNINGS should be treated as a warning, and don't necessarily indicate a problem with your config.
  Please |DON't| report these warnings as an issue.

Checking your config ~
- WARNING |mini.icons| is not installed
- OK |nvim-web-devicons| is installed

Checking for issues with your mappings ~
- OK No issues reported

checking for overlapping keymaps ~
- WARNING In mode `n`, <gc> overlaps with <gcc>:
  - <gc>: Toggle comment
  - <gcc>: Toggle comment line
- OK Overlapping keymaps are only reported for informational purposes.
  This doesn't necessarily mean there is a problem with your config.

Checking for duplicate mappings ~
- OK No duplicate mappings found

Log

Debug Started for v3.11.1
new Mode(n:1)
Trigger(add) Mode(n:1) ' " ` z= g' g` <Space>
on_key: <Space>
State(start): Mode(n:0) Node(<Space>) { keys = "<Space>" }
  update Mode(n:1)
  continue: <Space> Mode(n:1)
  getchar
  on_key: e
  got: e
  suspend: Mode(n:1)
  Trigger(del) Mode(n:1) z= ' g' " <Space> g` `
  feedkeys: Mode(n:1) <Space>e
on_key: <Space>e
BufNew(4)
BufEnter(4)
  new Mode(n:4)
BufEnter(4)
Trigger(add) Mode(n:1) ' " ` z= g' g` <Space>
Trigger(add) Mode(n:4) ' " ` z= g' g` <Space>
on_key: <Space>e
BufEnter(1)
on_key: <Space>
on_key: :
ModeChanged(n:c)
  new Mode(c:1)
  Safe(true)
Trigger(add) Mode(c:1) <C-R>
on_key: q
on_key: <CR>
ModeChanged(c:n)
  Unsafe(command-mode)
  suspend: Mode(n:1)
  Trigger(del) Mode(n:1) ' ` z= g' g` "
Trigger(add) Mode(n:1) ' " ` z= g' g` <Space>

Repro

vim.g.mapleader = " "
vim.g.maplocalleader = " "

vim.keymap.set("n", "<leader>e", "<cmd>Neotree toggle reveal_force_cwd<cr>", { desc = "[E]xplorer" })

vim.env.LAZY_STDPATH = ".repro"
load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()

require("lazy.minit").repro({
  spec = {
    { "folke/which-key.nvim", event = "VimEnter", opts = {
  triggers = {
    { "<leader>", mode = { "n", "v" } },
  },

    } },
    -- add any other plugins here
    {
        "nvim-neo-tree/neo-tree.nvim",
        branch = "v3.x",
        dependencies = {
          "nvim-lua/plenary.nvim",
          "nvim-tree/nvim-web-devicons", -- not strictly required, but recommended
          "MunifTanjim/nui.nvim",
          -- "3rd/image.nvim", -- Optional image support in preview window: See `# Preview Mode` for more information
        }
    },
  },
})
folke commented 1 month ago

That's on purpose. If a keymap already exists for a trigger, then no trigger will be created.

Kuwagata commented 1 month ago

@folke I'm experiencing a similar problem with telescope. I have <leader>ff bound to telescope's builtin find files (lazy loaded), and whenever I try to use it, which-key no longer responds after dismissing telescope. This wasn't happening prior to the major version bump, so I'm wondering if there's a new configuration that needs to be set to get it working again.

Is there a way to get which-key to forcefully re-bind in in this case, or is this possibly telescope (and neo-tree for the other user) not restoring bindings like it should?

folke commented 1 month ago

This has nothing to do with op's problem. Open an issue with a working repro that shows the issue. Without a repro I'm not going to look at it. Sorry.