feature: Command palette with telescope
Did you check the docs?
- [x] I have read all the which-key.nvim docs
Is your feature request related to a problem? Please describe.
Getting a hint while typing is really useful, but only when the typist knows how to start a combination.
It would be nice to be able to browse them like a command palette! This can be done by integrating into telescope.nvim.
It makes sense to allow searching by both the description and the key strokes.
Describe the solution you'd like
Telescope allows you to provide custom pickers. It should be possible to just hook into telescope if its available on the user's instance.
It doesn't make sense to require Telescope as a dependency since not all users might want that, but having an out-of-the-box bridge between two plugins that are very popular could be very nice. Integrating into an existing plugin will save a lot of work.
Besides, which-key.nvim is included in kickstart.nvim. Having a palette for querying keys is useful to both VSCode refugees and general beginners.
Describe alternatives you've considered
It possible to have it as a separate plugin or a recipe in the README.
Additional context
Conversion of new users and accessibility has been very important for Neovim's resurgence and I think this feature will help both causes.
As a side note, in normal mode (probably others too, have only verified normal mode so far) you can get a list of all available normal mode keystrokes by pressing any key that starts a two- or three-key command (such as <Leader>, i.e. the space bar in LazyVim's default keymap) and looking at the bottom of the which-key popup. Is there a backspace symbol there? If so, press it and you'll see all the available first keystrokes, which is exactly what you're asking for.
@rmunn, good call! Checked on my setup, works too. This is mentioned in the docs, but only in passing as a method of navigation.
https://github.com/folke/which-key.nvim/blob/370ec46f710e058c9c1646273e6b225acf47cbed/doc/which-key.nvim.txt#L413
This almost covers the case of searching by pressing keystrokes. If the command palette is greenlit, it makes sense to document that similar behavior is present in the vanilla version.
- Telescope has builtin
Telescope keymaps. - Snacks.picker has builtin
lua Snacks.picker.keymap(). - fzf-lua also has builtin
Fzf keymaps.
There's also the <Leader>? (space bar then question mark if you haven't remapped your <Leader> key to something other than the default space bar) combination. It gives you a list of the most common keystrokes available in your current window. It's not a complete list, but it does list key combinations, e.g. do it in an editor window with some source code file open and you'll see entries like gd → Goto Definition and gD → Goto Declaration. I haven't tracked down where the list is coming from, but I believe it's probably explicitly provided by a plugin rather than calculated from all available keymaps, whereas the <Leader><BS> combination (space bar then backspace) is clearly auto-calculated from all available keymaps.
I only discovered the <Leader>? combination myself, just now, by looking closely at the which-key window. It should perhaps be more prominently documented. It doesn't use telescope or other pickers so it's not exactly what you asked for, but it's another thing that partly fulfills your request.
There's also the
<Leader>?(space bar then question mark if you haven't remapped your<Leader>key to something other than the default space bar) combination. It gives you a list of the most common keystrokes available in your current window. It's not a complete list, but it does list key combinations, e.g. do it in an editor window with some source code file open and you'll see entries likegd → Goto DefinitionandgD → Goto Declaration. I haven't tracked down where the list is coming from, but I believe it's probably explicitly provided by a plugin rather than calculated from all available keymaps, whereas the<Leader><BS>combination (space bar then backspace) is clearly auto-calculated from all available keymaps.还有<Leader>?(如果您尚未将<Leader>键重新映射到默认空格键以外的其他键,则请按空格键然后问号)组合。它为您提供了当前窗口中最常用的按键列表。它不是一个完整的列表,但它列出了组合键,例如,在打开某些源代码文件的编辑器窗口中执行此操作,您将看到诸如gd → Goto Definition和gD → Goto Declaration之类的条目。我还没有找到该列表的来源,但我相信它可能是由插件明确提供的,而不是根据所有可用的键盘映射计算得出的,而<Leader><BS>组合(空格键然后退格键)显然是根据所有可用的键盘映射自动计算得出的。I only discovered the
<Leader>?combination myself, just now, by looking closely at the which-key window. It should perhaps be more prominently documented. It doesn't use telescope or other pickers so it's not exactly what you asked for, but it's another thing that partly fulfills your request.我刚才仔细查看了 which-key 窗口,才发现了<Leader>?组合。或许应该更详细地记录它。它没有使用望远镜或其他选择器,所以它并不完全符合你的要求,但它也部分满足了你的要求。
@rmunn
<leader>? is not mapped by which-key.nvim by default(I guess you should had greped the word in this repo before you assumes that it is mapped). You are using a distro, something like LazyVim, which just mapped <leader>? to require("which-key").show({ global = false }) for you.
Edit: just grepped the keymap and found out it's already a recommended keymap in :help which-key.nvim-which-key-installation.
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.
This issue was closed because it has been stalled for 7 days with no activity.