Closed practicalli-johnny closed 3 months ago
Hm not sure how you add names for submenus, I guess that's another API call for which-key specifically? I only know how to set desc
on each mapping, not the keys that lead up to the mapping, I suspect there is a specific thing that needs to be done to inform which-key of these intermediate keys, I don't define g
as an explicit prefix for example, there just might be two commands that use g
in their sequence, so you end up with an ambiguous sub-menu in which-key.
I'll take a look, thanks for raising it!
Which-key version 3 was released about a week ago and this has an add function that may make it easier to add sub-menu names
In theory it should be as simple as providing the key mapping and name text for each sub-menu
Hm I don't think I can do this 🤔 say Conjure uses the <prefix>e...
prefix for some eval related things, but then another plugin also uses <prefix>ejy
and then the user adds a custom one under <prefix>epo
. That means I can't just say "hey, everything under <prefix>e
will be to do with Conjure's eval and nothing else".
I think the which-key API is really there for people to use in dotfiles when they know what will be under a particular part of the tree, Conjure can't guarantee that though. Are there examples of other plugins that do this?
Because the only example I can think of / see in my setup (based on AstroNvim) are the menus that AstroNvim sets up with the knowledge of which plugins are loaded and under which configured mappings. So I think this is more of a user space thing and I think Conjure would be overstepping it's boundaries if it started to meddle with users which key configs.
It'll also be really difficult to do, if the user remaps some of the mappings I then need to somehow detect groups of mappings and label the appropriately. I could maybe say "I will set up which key labels of groups if you don't change any mappings", but that feels a little lacklustre.
So although I like the idea of this on the surface, I think it becomes a bit too difficult and has too many potential downsides to pull off. I think the better approach would be a wiki page that shows the which-key config you'd need to label the groups provided you left them as defaults that people could copy into their config if they wanted to. We can assume that if a user is very invested in which-key they already have a section of their dotfiles dedicated to labelling their custom mappings and groups for all of the plugins they use.
So thank you for this idea, it was interesting to explore, but I think it's just not the place to implement it.
ℹ️ Adding configuration under the after/ftplugin/
directory will load that configuration each time the relevant filetype is set in the current buffer.
Adding the which-key sub-menu names via a after/ftplugin/clojure.lua
file only shows those menu names when a Clojure filetype is the current buffer.
Including which-key and adding the names using the group key provides the menu names in the Practicalli Astro configuration (built on AstroNvim 4).
-- Configure loaded after clojure filetype set in current buffer
local whichkey = require "which-key"
return {
{
"folke/which-key.nvim",
-- Load Conjure Groups only for Clojure filetypes
whichkey.add {
-- Conjure sub-menus
{ "<LocalLeader>c", group = "Connect" },
{ "<LocalLeader>e", group = "Evaluate" },
{ "<LocalLeader>ec", group = "Comment" },
{ "<LocalLeader>g", group = "Go" },
{ "<LocalLeader>l", group = "Log" },
{ "<LocalLeader>r", group = "Refresh" },
{ "<LocalLeader>s", group = "Session" },
{ "<LocalLeader>t", group = "Test" },
{ "<LocalLeader>v", group = "Values" },
},
},
}
Consider adding names to the which-key menus for conjure.
With a Clojure file open, pressing shows a which-key with conjure sub-menus. Each menu has a text description
prefix
rather than a word or brief sentence describing the commands under each menuEach command has a description, its only their parent menus that do not have a description.
Consider adding descriptive names, for example something like this (at least for the clojure client)
c
connecte
evaluateg
gol
logr
refreshs
repl sessiont
testv
viewIt seems that fnl/conjure/mapping.fnl sets the description for each command.
I could not find code that sets the names of the sub-menus or related issues. Apologies if I've raised a duplicate issue.