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.38k stars 177 forks source link

bug: Remapped registers key doesn't trigger which-key #537

Closed happenslol closed 3 months ago

happenslol commented 12 months ago

Did you check docs and existing issues?

Neovim version (nvim -v)

v0.9.4

Operating system/version

NixOS 23.11.20231024.8efd5d1

Describe the bug

I've remapped my registers key to ', and I can't get which-key to trigger when pressing it.

I've already looked at #483, where the following was suggested:

{
  'folke/which-key.nvim',
  config = function()
    local actions = require("which-key.plugins.registers").actions
    table.insert(actions, { ... }) -- Add remapped triggers here
    require("which-key").setup()
  end,
}

This does not do anything for me. I've included this as a step in the reproduction below.

Steps To Reproduce

  1. Remap the registers key
vim.keymap.set({ "n", "v" }, "'", "\"")
  1. Apply the fix suggested in #483
{
  "folke/which-key.nvim",
  config = function(_, opts)
    -- Show registers when pressing remapped ' key
    local registers_actions = require("which-key.plugins.registers").actions
    table.insert(registers_actions, { trigger = "'", mode = "n" })
    table.insert(registers_actions, { trigger = "'", mode = "v" })
    require("which-key").setup()
  end,
},
  1. Press '

Expected Behavior

The registers which-key window should show, but nothing happens. The window still shows when pressing ".

Repro

No response

bommbo commented 11 months ago

You can try it like that, but it is not possible to remap the character "\"" to "'".

    keys = {
      { "'", "\"", desc = "keyremap", mode = { "n", "v" }, remap = true },}
github-actions[bot] commented 4 months 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.

happenslol commented 4 months ago

Not stale, still relevant

happenslol commented 2 months ago

I can still not get this to work, neither by just remapping nor by applying the following fix:

local registers_mappings = require("which-key.plugins.registers").mappings
table.insert(registers_mappings, { "'", mode = { "n", "x" }, desc = "registers" })

Am I missing something here?