Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non leader keys #113

Closed
nkcfan opened this issue May 5, 2020 · 10 comments · Fixed by #206
Closed

Non leader keys #113

nkcfan opened this issue May 5, 2020 · 10 comments · Fixed by #206

Comments

@nkcfan
Copy link

nkcfan commented May 5, 2020

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.

  1. It only shows me the user defined key mappings, no vim default such as 'gJ'
  2. 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

@liuchengxu
Copy link
Owner

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.

@nkcfan
Copy link
Author

nkcfan commented Jan 24, 2021

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".

@AckslD
Copy link
Contributor

AckslD commented Mar 5, 2021

@nkcfan With these settings goes operators such as gu/gU work for you?

@nkcfan
Copy link
Author

nkcfan commented Mar 5, 2021

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?

@AckslD
Copy link
Contributor

AckslD commented Mar 5, 2021

Did you mean gU and not gUU? For me for example doing a word caps by gUiw does not work.

@nkcfan
Copy link
Author

nkcfan commented Mar 5, 2021

gUiw is not working either.

@AckslD
Copy link
Contributor

AckslD commented Mar 5, 2021

Didn't know about the guu gUU commands actually, so learnt something new 🙂 But indeed not working

@AckslD
Copy link
Contributor

AckslD commented Mar 11, 2021

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.

@acdifran
Copy link
Contributor

acdifran commented Nov 11, 2021

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:

acdifran@de022f6

@liuchengxu happy to submit a PR if this looks good to you

@liuchengxu
Copy link
Owner

@acdifran That looks good to me, feel free to send a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants