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

feature: Recursively expand #767

Closed mrmarkwell closed 1 month ago

mrmarkwell commented 1 month ago

Did you check the docs?

Is your feature request related to a problem? Please describe.

I have some longer key maps, e.g.

vim.keymap.set('n', '<leader>help', builtin.help_tags, { desc = 'search [help]' })

and even though they qualify to be expanded:

expand = function(node)
   -- Expand if there is no description.
   return not node.desc
end,

The expansion only goes one level down:

  c ➜   +[C]ode
  d ➜   +[D]ocument
  f ➜   +[F]ind
 he ➜   +1 keymap
  r ➜   +[R]ename
  s ➜   +[S]earch
  w ➜   +[W]orkspace

Describe the solution you'd like

It would be cool if the expansions continued recursively if the next level down also qualified for expansion:

    c ➜   +[C]ode
    d ➜   +[D]ocument
    f ➜   +[F]ind
 help ➜   search [help]
    r ➜   +[R]ename
    s ➜   +[S]earch
    w ➜   +[W]orkspace

Describe alternatives you've considered

I could make the mapping: <leader>sh so the expansion only has to go one level down.

I just have a handful of keymaps that are longer, since it is easier for me to remember and I don't mind typing a few extra characters. (e.g. for project CoolProject, I might map <leader>scool to search the cool project with telescope.)

Not a big deal if this is tricky to implement, just a suggestion. Either way, thanks for your contributions to Neovim!

Additional context

No response

folke commented 1 month ago

expanding is now always recursive, so your mapping should work as expected. Thank you for the suggestion!

mrmarkwell commented 1 month ago

Confirmed that this works, thanks!