liuchengxu / vim-which-key

:tulip: Vim plugin that shows keybindings in popup
https://liuchengxu.github.io/vim-which-key/
MIT License
1.93k stars 65 forks source link

Exit key setting to a list of keys doesn't work #244

Closed Twix53791 closed 1 year ago

Twix53791 commented 1 year ago

Environment:

Plug 'liuchengxu/vim-which-key'

call plug#end()

let g:which_key_map = {} let g:mapleader = "," nnoremap :WhichKey ',' call which_key#register(',', "g:which_key_map")

let g:which_key_exit = ["\", "\", "\"]


**Describe the bug**
When I put the keys into a list, none of each works, to exit the menu I have to select an entry. Curiosly, each key set separatly like `let g:which_key_exit = "\<S-CR>"`, outside of a list, works.

**To Reproduce**
Steps to reproduce the behavior:

1. Create the minimal vimrc `min.vim`:
```vim
call plug#begin('~/.config/nvim/plugins')

Plug 'liuchengxu/vim-which-key'

call plug#end()

let g:which_key_map =  {}
let g:mapleader = ","
nnoremap <silent> <leader> :<C-u>WhichKey ','<CR>
call which_key#register(',', "g:which_key_map")

let g:which_key_exit = ["\<Esc>", "\<S-CR>", "\<A-CR>"]

Expected behavior I found on github many personal vim configs setting which_key_exit as a list of keys, so I am surprised it doesn't functionate on my config...

liuchengxu commented 1 year ago

There is indeed a regression here, which should be fixed by #246. However, keys like "\<S-CR>" are not guaranteed to work in vim, you have to use the distinguishable keys, please refer to https://stackoverflow.com/questions/5388562/cant-map-s-cr-in-vim for more info.

Twix53791 commented 1 year ago

Thank you! the fix works for me! I am aware about the possible impossibility of some bindings, but with kitty terminal, control mappings is easy :)