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

invalid mode shortname #12

Closed
klooj opened this issue Apr 29, 2021 · 12 comments
Closed

invalid mode shortname #12

klooj opened this issue Apr 29, 2021 · 12 comments

Comments

@klooj
Copy link

klooj commented Apr 29, 2021

image

Is this on me?

To give this plugin a quick test run, I tried setting it up for descriptions only. So

  1. in packer: use {'folke/which-key.nvim', config = [[require('wk')]]}
  2. wk.lua just has the copy pasta default opts inside the wk.setup function, and then require('maps')
  3. maps.lua is a longer version of:
local wk = require('which-key') 
local opts = {mode = 'n', prefix = '<leader>', buffer = nil, silent = true}
local maps = {
  [','] = 'comment',
  ['.'] = 'vimrc',
  [';'] = 'substitute',
  ['\\'] = 'nv tree',
  ['<Left>'] = 'mv buffer next',
  ['<Right>'] = 'mv buffer previous',
  ['='] = 'balance windows',
  ['h'] = 'split below',
  ['H'] = 'treesitter highlight',
  ['j'] = 'any jump',
  ['k'] = 'pick buffer',
}
wk.register(maps, opts)
@folke
Copy link
Owner

folke commented Apr 29, 2021

Thank you for reporting. When exactly does this error appear?

Just tried your config and it works. Is there a certain prefix that triggers this error?

@klooj
Copy link
Author

klooj commented Apr 29, 2021

hmmm. it happens immediately upon pushing the leader key. maybe there's a leftover parameter or clash somewhere from another which-key plugin. i'll debug some more to isolate it.

@folke
Copy link
Owner

folke commented Apr 29, 2021

Just to be sure you don't call :WhichKey on <leader> right? No need to do that as with vim-which-key.

@klooj
Copy link
Author

klooj commented Apr 29, 2021

It also seems to effect the d and g keys in normal mode. So neither d$ nor gg do anything. I'm kinda stumped.

@klooj
Copy link
Author

klooj commented Apr 29, 2021

ok ya that definitely is it.

@klooj klooj closed this as completed Apr 29, 2021
@folke
Copy link
Owner

folke commented Apr 29, 2021

@klooj great. Can you show the exact keympaping you had in place that caused this?

I'll see if I can show a warning when someone else has leftovers from vim-which-key and handle it properly

@PSeitz
Copy link

PSeitz commented Apr 29, 2021

I had this nnoremap <silent> <Leader> :WhichKey '<Space>'<CR>

@klooj
Copy link
Author

klooj commented Apr 29, 2021

fershur. so there were two parts:

first, this is how i set my leader keys. i had to comment out those 4 lines in order for the popup to work. i think it's just a timing thing that could be fixed on my end.
image

second, these are the keymaps i had (they're wrapped in a custom function )
image

@folke
Copy link
Owner

folke commented Apr 29, 2021

That definitely caused it. You don't need to set any special keymaps for WhichKey to work.
Just pushed a change that shows an error when such a invalid keymap is called, so other users with the same issue will know what to do. Also updated the README.

@folke
Copy link
Owner

folke commented Apr 29, 2021

Your first 4 lines in the first screenshot are <nop> operations, so if those were loaded AFTER WhichKey, it wouldn't work. But why would you want to add these in, in the first place? :)

@klooj
Copy link
Author

klooj commented Apr 29, 2021

You are correct. When using certain gui's for nvim, they mess with the mapping of leader keys. So I put that in there to take control of the situation. I thought I called that function before loading any plugins but apparently my timing is off. Not a big deal at all though, rarely use a gui anymore.

Getting the perfect portable vimrc is comically similar to whack-a-mole.

@klooj
Copy link
Author

klooj commented Apr 29, 2021

this plugin is great. everything is working and I was able to jettison two plugins (vim-peekabo and vim-signature). three plugins for the price one.

fwiw, you may want to use wk.register({["j"] = "which_key_ignore", ["k"] = "which_key_ignore"}) for the example in the readme, so that people who have jk jj kj etc mapped to esc in insert mode can copy paste or at the very least be gently reminded they'll need to do it.

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

No branches or pull requests

3 participants