integrate with telescope.builtin.keymaps? #893
Replies: 4 comments 2 replies
-
I see that there's another discussion about how |
Beta Was this translation helpful? Give feedback.
-
I now have an actual idea, if there's a function that I can call to construct my own description when it's printed, then I could concatenate together my own 'full' description string from the groups of all the prior keys 🤔. If I figure something out I'll post it here. I think this would fall under the domain of |
Beta Was this translation helpful? Give feedback.
-
I feel like i'm onto something here, at least it seems to be all good from the Telescope side. I've copy-pasted the original impl for the keymaps picker and found the spot where I would need to iterate over the groups I have set in (currently there's a current code : https://github.com/JulianNymark/configs/blob/master/nvim/lua/telescope_grouped_keymaps.lua |
Beta Was this translation helpful? Give feedback.
-
I hacked together something that works! (at least it's a PoC) 🎉 My own picker for telescope (based on the original builtin keymaps picker) now looks up the keymap substrings to the left and concatenating the groups description if it matches a group. Below you can see the output of the picker. I have groups set to the following: wk.add({
{ "<leader>b", group = "[b]rowse" },
{ "<leader>c", group = "[c]ode" },
{ "<leader>d", group = "[d]ocument" },
{ "<leader>f", group = "[f]ile" },
{ "<leader>g", group = "[g]it" },
{ "<leader>gl", group = "[l]ist" },
{ "<leader>h", group = "Git [h]unk" },
{ "<leader>n", group = "[n]oice" },
{ "<leader>r", group = "[r]efactor" },
{ "<leader>s", group = "[s]earch" },
{ "<leader>t", group = "[t]oggle" },
{ "<leader>w", group = "[w]orkspace" },
{ "<leader><leader>", group = "utility" },
}) I never wrote those full descriptions myself, as the keymap + desc for eg. vim.keymap.set("n", "<leader>tt", "<cmd>Twilight<CR>", { desc = "[t]wilight (focus scope hl)" }) It doesn't say anything about how it currently worksI found the values of keymaps / groups via The full source code for this picker is in the same link as above https://github.com/JulianNymark/configs/blob/master/nvim/lua/telescope_grouped_keymaps.lua To test it out you can source the file and it registers a hotkey at the bottom to trigger it with |
Beta Was this translation helpful? Give feedback.
-
(warning: newbie alert, I'm still figuring things out, and this idea might fall between the two plugins
which-key
andtelescope
... which is fully understandable 😅 )But my idea was that since I use these two (amazing!) plugins together, I think it would be nice to have the "full docs" of all the intermediate keymap keys joined together in the final description of what's listed in
telescope.builtin.keymaps
.(hopefully minimal) Example:
I register a "keymap grouping" in which-key like this:
I then set a keymap that doesn't fully describe the keymap (only the last "fragment"). A good description of this keymap would be "[t]oggle [t]wilight (focus scope hl)".
This works great within
which-key
, since I step through the kemaps one by one, and I get to "piece together the full description" this way. But then in other tooling such astelescope.builtin.keymaps
. If I search up this keymap, all i get is the following:Here I don't get to see what the earlier keys "mean" (how I decided to group them).
It's not a huge deal, since I tend to learn my prefixes / groupings faster than the leaf-node keymaps themselves, but it would be amazing if there was a way for me to do some kind of concatenation of the
which-key
register names / descriptions.This might be a silly question, and maybe there's a way to do this already (with some choice lua), so if anyone has any ideas (I don't even need fully working lua snippets to start my investigation either) please add them here! 🙌
Beta Was this translation helpful? Give feedback.
All reactions