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: keybinding group added with after/ftplugin not shown #625

Closed cova-fe closed 1 month ago

cova-fe commented 2 months ago

Did you check docs and existing issues?

Neovim version (nvim -v)

NVIM v0.10.0

Operating system/version

MacOS 14.5 (23F79)

Describe the bug

I have enable wich-key with several keybindings using global configuration. Then I added a ftplugin config file, so to activate a menu only for specific filetypes. The idea is to have all language specific keybindings under a group with "l" as main keybinding, and have all the subkeys dynamically changed according to the filetype. This setup works, but the group keybinding is not shown in the popup when pressing "leader" key; however the key is active and opens the "language specific" group.

Steps To Reproduce

My lua files setup: (some code is derived from lunarvim, and it is just a crude example) after/ftplugin/go.lua

local kb = require "fvim.keybindings"

kb.l_keys({
  name = "Golang",
  b = { "<cmd>GoBuild<cr>", "Build" },
  r = { "<cmd>GoRun<cr>", "Run" },
  i = { "<cmd>GoImports<cr>", "Imports" },
  v = { "<cmd>GoVet<cr>", "Vet" },
  d = { "<cmd>GoDoc<cr>", "Doc" },
  o = { "<cmd>GoPkgOutline<cr>", "Outline" },
  m = { "<cmd>GoModInit<cr>", "Mod Init" },
  M = { "<cmd>GoModTidy<cr>", "Mod Tidy" },
  I = { "<cmd>GoToggleInlay<cr>", "Toggle Inlay" },
})

fvim.keybindings function definition:

M.l_keys = function(keys)
  local which_key = require "which-key"
  local k = { l = {} }
  k.l = keys
  which_key.register(k)
end

return M

Expected Behavior

"l" group keybinding is shown on main popup. The key is active, just now shown

Repro

No response