feat(render): merge keybindings in UI #1332
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR updates the keybindings view in the "hints" section in lazy home.
Activation keys for plugins are now iterated in sorted order (by keys) and
common prefixes, if present, are shown instead of all the individual
keybindings.
Given a config like this:
The UI entry in the Not Loaded plugins now looks like this:
instead of previously:
As a side-effect, this ensures that, even if no "common prefix" exists, keys
are always shown in sorted order.
Additional remarks
Compound keybindings
I assume that the current implementation fails when "Ctrl"-based keybindings
are mixed with anything that has "C" as a prefix, for example. I'm not sure
about the exact notation of Ctrl-/Alt-keybindings in nvim because I never use
them, but a quick test with this setup:
shortens the whole group to
<leader>C
in the UI, where it should probablyshow
<leader>C <leader>C-d
instead. In a similar fashion, I assume that ascenario like this fails as well:
although I'm unsure whether this is a realistic scenario to consider here. Is
there something like an iterator over individual/compound keys in the raw data?
Or do I have to check whether
C-?
is part of a compound binding myself? Ifso, do you know of any other compound bindings I should be aware of?
which-key integration
Users of which-key will probably not benefit from this change. That is
because keybinding groups must be registered in which-key directly (so the
"group"-prefix is picked up correctly), so lazy doesn't know about them. Since
keybindings can only be performed once, we cannot just "copy" the which-key
group assignment into lazy just for the UI.
I've opened a PR for which-key that solves this inconvenience, in case
you're interested.