Non leader keys
nkcfan opened this issue ยท 10 comments
Is your feature request related to a problem? Please describe.
Seems vim-which-key is designed to work with key mappings following leader or localleader. I experiment it with other leading char, such as g
which is commonly used. I notice some issues.
- It only shows me the user defined key mappings, no vim default such as 'gJ'
- The vim default key mappings are totally broken, either typed faster or slower than the timeout. The error message is
[which-key] g J is undefined
Describe the solution you'd like
I am ok if it is difficult to show the vim default key mappings, but I really wish they still work.
Describe alternatives you've considered
Not to use vim-which-key with non leader characters.
Additional context
N/A
No only the leader and localleader, but also any key mappings defined explicitly.
vim-which-key retrieves the info of key mappings via :map
, so it won't know the default mappings like gJ
. In another word, vim-which-key only works with the user defined mappings, or you can create a runtime mapping by defining them in the Dict.
It's possible to also support the builtin default mappings, but someone needs to spend time on it. Related #14.
I found what I want exactly.
nnoremap <silent> g :<C-U>WhichKey 'g'<CR>
let g:which_key_fallback_to_native_key = 1
The vim default key mappings are still not shown, but they are accepted instead of banned as "[which-key] ... is undefined".
Cool catch! I tested guu
/gUU
, and neither works. Seems the solution is only for two-key binding.
@liuchengxu Do you think it is a bug?
Did you mean gU
and not gUU
? For me for example doing a word caps by gUiw
does not work.
gUiw
is not working either.
Didn't know about the guu gUU commands actually, so learnt something new
Btw, just noticed that with the above settings also commands such as z=
have issues. It opens the choices for spell corrections but doesn't allow the choice.
The fallback call only works for 2 key mappings since it is calling the entered keys immediately.
I believe I have a fix for this, using feedkeys with the "Do not remap keys" modifier. Seems to be working for me so far:
@liuchengxu happy to submit a PR if this looks good to you
@acdifran That looks good to me, feel free to send a PR.