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

Feature request: Support for local leader #35

Closed
wren opened this issue May 1, 2021 · 8 comments
Closed

Feature request: Support for local leader #35

wren opened this issue May 1, 2021 · 8 comments
Labels
question Further information is requested

Comments

@wren
Copy link

wren commented May 1, 2021

Hi! I just wanted to say thank you for this plugin. I've been using the old which key for a while. But when I recently ported over my config to lua, I found that there was a lot of functionality I would like that wasn't quite there. And this plugin has a lot of that, so thank you!

Anyway, everything is working great, but I'd like to request that <LocalLeader> be supported the same way that <Leader> currently is.

Thanks, again!

@folke
Copy link
Owner

folke commented May 1, 2021

<localleader> should already work in combination with buffer=123.

Can you clarify specifically what doesn't work right now?

@folke folke added the question Further information is requested label May 2, 2021
@folke
Copy link
Owner

folke commented May 3, 2021

If you had issues with the default <localleader> set to \, then that should be resolved now.

@wren
Copy link
Author

wren commented May 4, 2021

Hi, and sorry for the slow response!

My local leader is set to semicolon (;), and what doesn't work for me is that which-key doesn't trigger after I press ;. It does trigger when I press any other key, and it also happens if I run it by command (:WhichKey ;), but otherwise I can't seem to get it to work like it does for the other keys.

Forgive me, but I'm not clear on what you mean by the suggestion above about using buffer=123. Should I pass in a function to buffer that always returns the number of the buffer I'm on? Or did you mean something else?

@folke
Copy link
Owner

folke commented May 4, 2021

Nevermind the buffer stuff. That's needed if you want buffer-local mappings.

Using ; as your local leader should work as expected. Just tested it myself and it triggers WhichKey.

Can you post a bit more about your (code) configuration? Specific keymapping that doesnt work?

Are you certain you define your maplocalleader before setting any keymaps?

Are you using the latest version of WhichKey?

@wren
Copy link
Author

wren commented May 4, 2021

My entire nvim setup is here, but the specific file for those mappings is here. It's the first thing that happens on init other than defining a few helper functions.

And with your guidance, I think I found the problem. Since ; is my local leader and also a default vim keybinding, I unmap the default (further down in that same file). I do this because ; will go back to the default functionality in buffers with no local bindings (and I kept accidentally doing it).

When I remove that line then whichkey works as expected. The strange part, though, is that I do the exact same thing with space (which is my leader), but whichkey doesn't seem to mind either way in that case.

folke added a commit that referenced this issue May 5, 2021
@folke
Copy link
Owner

folke commented May 5, 2021

I just pushed a change.

WK never creates hooks for keybindings that already exist.

Your ; was an existsing keybinding (to <nop>).

It worked for <leader> since I already make a change to allow overwriting a leader set to <nop>

I just changed it so that keybindings are allowed to be overwritten when they are effectively <nop>s

@wren
Copy link
Author

wren commented May 7, 2021

Oh, right, I completely forgot about that. Using nvim_del_keymap on default keybindings has some really unexpected behavior with some plugins, so I went with the no-op.

Anyway, I tested this and it works perfectly. Thank you for the speedy fix!

@folke
Copy link
Owner

folke commented May 7, 2021

Great, thanks!

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

No branches or pull requests

2 participants