liuchengxu/vim-which-key

[which-key] <space> is undefined

eduardoarandah opened this issue · 4 comments

  • OS:

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.3 LTS"

  • (Neo)Vim version:
    NVIM v0.4.3
  • vim-which-key version: how to know this?
  • Have you reproduced with a minimal vimrc: no

Describe the bug

For some reason, nvim doesn't accept the mappings in my vimrc (UTF-8)

nnoremap <silent> <leader> :WhichKey '<Space>'<CR>

BUT if I take that line and execute it directly in the command line , then it works!!! strange

Any ideas?

This is my configuration, I get [which-key] <space> is undefined

Any ideas?

Plug 'liuchengxu/vim-which-key', { 'on': ['WhichKey', 'WhichKey!'] }
let g:mapleader = "\<Space>"
nnoremap <silent> <leader> :<c-u>WhichKey '<Space>'<CR> 

  1. Your mapleader does not need to be escaped, and the name for the space character is <space>

  2. You must also set up your g:which_key_map. Follow the docs to do so.

  3. You need to bind your config to WhichKey using the built in method call WhichKey#register("<space>", "g:which_key_map")

I was having the same issue as you and it turned out I needed to make all my mappings set to <space>. Here is an example:

" vim leader
let mapleader='<space>' 

" WhichKey leader mapping
nnoremap <silent> <space> :WhichKey <space><cr>
vnoremap <silent> <space> :WhichKeyVisual <space><cr>

" WhichKey mappings
let g:which_key_map = {}

" YOUR MAPPINGS HERE ======

" bind WhichKey
call WhichKey#register("<space>", "g:which_key_map")

@LoveSponge has provided a good explanation, and there is also a min example in https://github.com/liuchengxu/vim-which-key/wiki/mimimal-vimrc