Open lyndhurst opened 3 years ago
Thanks for opening this, I think it's a nice-to-have feature, but I have been too busy recently so PR is welcome :D.
This function is to create the display lines from the origin key mappings: https://github.com/liuchengxu/vim-which-key/blob/2c915b6de918c073fbd83809e51343651f00f9a8/autoload/which_key/renderer.vim#L83
Thank you for the pointer; I do not know vimscript very well, but I will try to hack at it. Hopefully someone more competent will come to the rescue :)
I tried to read through the issues and the doc as well as I could, and all I found related to sorting, was vertically/horizontally sorted options, and dictionaries vs loose keys first/last. I hope I did not miss anything there.
My shortcuts are mostly organized as mnemonics, and can be grouped by prefixes which is perfect for which-key default sorting. Sometimes though, adding a prefix would be an unnecessary keystroke added to the combination, and I also have some prefixes shared between unrelated functionalities. I also see it as a good practice to stick (more or less) to original vim mappings as much as I can, so it adds complexity to have them grouped by (sub) prefixes.
The problem when entries are sorted by keys, is that keys do not get grouped logically by functionality. Unfortunately my brain looks for keys by category, function, and not alphabetically.
An obvious way to solve that problem and increase which-key guide readability dramatically (for me at least) would be to sort the keys by their descriptions, this way all the user has to do is label them logically.
Let's see a simple example for window shortcuts to illustrate what I mean. Consider the following mappings and descriptions for moving, splitting, and navigating windows. This is how thy appear by default after typing
<Leader>w
:b
=> 'win-go-bottom-left'h
=> 'win-go-left'H
=> 'win-move-left'l
=> 'win-go-right'L
=> 'win-move-right'T
=> 'win-move-tab-new'r
=> 'win-rotate's
=> 'win-split't
=> 'win-go-top-left'v
=> 'win-split-vert'I feel it is much quicker to find what I am looking for when sorted by description:
b
=> 'win-go-bottom-left'h
=> 'win-go-left'l
=> 'win-go-right't
=> 'win-go-top-left'H
=> 'win-move-left'L
=> 'win-move-right'T
=> 'win-move-tab-new'r
=> 'win-rotate's
=> 'win-split'v
=> 'win-split-vert'I do not know how much complexity this would add to the code, but on the user side, I feel it would provide an easy and flexible way to gain significant control over the mappings display. It also offers a 'visual grouping' alternative to prefixes which present the disadvantage add key strokes to the user mappings.
Thanks for considering it, and sharing your opinions.