Fork me on GitHub
#vim
<
2022-10-07
>
walterl00:10:56

Has anyone else noticed :WhichKey '<LocalLeader>' bombing out with errors like these?

Error detected while processing function which_key#start[20]..<SNR>159_cache_key[4]..which_key#mappings#parse:                                                                                                                                                                                                           
line   19:
E716: Key not present in Dictionary: "rhs])"
E116: Invalid arguments for function call
line   28:
E716: Key not present in Dictionary: "rhs, '<SID>', '<SNR>'.mapd['sid'].'_', 'g')"
E116: Invalid arguments for function substitute
line   36:
E716: Key not present in Dictionary: "display !~# 'WhichKey.*'"
line   19:
E716: Key not present in Dictionary: "rhs])"
E116: Invalid arguments for function call
line   28:
E716: Key not present in Dictionary: "rhs, '<SID>', '<SNR>'.mapd['sid'].'_', 'g')"
E116: Invalid arguments for function substitute
line   36:
E716: Key not present in Dictionary: "display !~# 'WhichKey.*'"
line   19:
E716: Key not present in Dictionary: "rhs])"
E116: Invalid arguments for function call
(It goes on for a few pages.) I'm guessing it's due to Conjure creating mappings directly (somehow) to Lua functions:
:map <LocalLeader>
...
n  <BS>rc      *@<Lua function 435>
                 Clear the refresh cache
n  <BS>ra      *@<Lua function 434>
                 Refresh all namespaces
n  <BS>rr      *@<Lua function 433>
                 Refresh changed namespaces
...

walterl00:10:54

And yes, my <LocalLeader> is mapped to <BS>

walterl00:10:40

I'd switch to which-key.nvim, but <BS> doesn't work with it

walterl00:10:27

Well, it works after manually executing :WhichKey <LocalLeader> ๐Ÿ˜ต

Noah Bogart00:10:01

Internally, vim converts leader to the leader key at read time so internally itโ€™s not <leader>ff, itโ€™s \ff

Noah Bogart00:10:09

Is that the case here?

walterl00:10:39

Don't think so. This looks plugin-specific.

๐Ÿ‘ 1
walterl00:10:17

Closest I can get which-key.nvim to behave like vim-which-key, is to add nnoremap <silent> <LocalLeader> :WhichKey '<LocalLeader>'<CR>, even though the README specifically says not to

๐Ÿ˜‚ 1
walterl00:10:53

Oh well, I guess that half-working hack with which-key-nvim is better than half-broken vim-which-key :man-shrugging: ๐Ÿ˜…

Olical12:10:54

This is because Neovim has direct to Lua function mappings now which lack the RHS portion of the mapping data. So plugins that try to access that blindly will now throw on ANY Neovim mapping that points at a Lua function. The old which key needs a safe check to support nil RHS or you can use the nvim / new one. If Conjure didn't trigger this bug, some other plugin would eventually, I'm just hopping on the Lua mapping train early because it's so much better and allowed me to fix bugs with vim repeat integration.

๐Ÿ‘ 2