folke / which-key.nvim

💥 Create key bindings that stick. WhichKey helps you remember your Neovim keymaps, by showing available keybindings in a popup as you type.
Apache License 2.0
4.76k stars 154 forks source link

Add support for key ranges to `key_labels` #614

Closed dlyongemallo closed 1 week ago

dlyongemallo commented 1 week ago

Did you check the docs?

Is your feature request related to a problem? Please describe.

First, thanks for a very useful plugin.

My problem should be a pretty common one. Modified function keys are numbered as if they were in higher ranges, i.e., Shift+{F1-F12} = F13-F24 Ctrl+{F1-F12} = F25-F36 Ctrl+Shift+{F1-F12} = F37-48 Alt+{F1-F12} = F49-F60

When I have a key mapped to Ctrl+F2, for example, it shows in WhichKey as <F26> which is not informative. I have an override in the config ['<F26>'] = '<Ctrl+F2>', but this has to be done for each key individually and it would obviously be much nicer to be able to supply a range.

Describe the solution you'd like

WhichKey should implicitly label <F13> as <S-F1>, etc., or support some way to specify ranges in the key_labels overrides.

Describe alternatives you've considered

It's obviously possible to just manually override all the key_labels in the range.

require("which-key").setup {
    key_labels = {
        ['<F13>'] = '<S-F1>',
        ['<F14>'] = '<S-F2>',
        ['<F15>'] = '<S-F3>',
        ['<F16>'] = '<S-F4>',
        ['<F17>'] = '<S-F5>',
        ['<F18>'] = '<S-F6>',
        ['<F19>'] = '<S-F7>',
        ['<F20>'] = '<S-F8>',
        ['<F21>'] = '<S-F9>',
        ['<F22>'] = '<S-F10>',
        ['<F23>'] = '<S-F11>',
        ['<F24>'] = '<S-F12>',
        ['<F25>'] = '<C-F1>',
        ['<F26>'] = '<C-F2>',
        ['<F27>'] = '<C-F3>',
        ['<F28>'] = '<C-F4>',
        ['<F29>'] = '<C-F5>',
        ['<F30>'] = '<C-F6>',
        ['<F31>'] = '<C-F7>',
        ['<F32>'] = '<C-F8>',
        ['<F33>'] = '<C-F9>',
        ['<F34>'] = '<C-F10>',
        ['<F35>'] = '<C-F11>',
        ['<F36>'] = '<C-F12>',
        -- etc.
    },
}

Additional context

I'd actually like to use Ctrl+ rather than C- (and also Alt+ rather than M-); this is already filed as #222.

folke commented 1 week ago

no

dlyongemallo commented 1 week ago

Okay, thanks for the quick response. Is there also no way to display Alt+ rather than M-?