Olical / conjure

Interactive evaluation for Neovim (Clojure, Fennel, Janet, Racket, Hy, MIT Scheme, Guile, Python and more!)
https://conjure.oli.me.uk
The Unlicense
1.71k stars 109 forks source link

[mappings] Conjure menu names not defined #585

Closed practicalli-johnny closed 4 weeks ago

practicalli-johnny commented 1 month ago

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 menu

image

Each command has a description, its only their parent menus that do not have a description.

image

Consider adding descriptive names, for example something like this (at least for the clojure client)

It 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.

Olical commented 1 month 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!

practicalli-johnny commented 1 month ago

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

Olical commented 1 month ago

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.