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

Unknown function which_key#register #53

Closed
dubst3pp4 opened this issue May 28, 2019 · 5 comments
Closed

Unknown function which_key#register #53

dubst3pp4 opened this issue May 28, 2019 · 5 comments
Labels

Comments

@dubst3pp4
Copy link

Hello, I'm using your great plugin with Vim 8.1. I've installed the plugin as a Git submodule into Vim's pack/plugins/start directory, so it gets loaded when Vim starts.

The plugin is working fine, but when I try to create a dictionary in my .vimrc, then I get the following error message:

E117: Unknown function: which_key#register

My configuration is very simple:

let mapleader=","

let g:which_key_map = {}
call which_key#register(',', "g:which_key_map")
nnoremap <silent> <leader> :<c-u>WhichKey ','<CR>
vnoremap <silent> <leader> :<c-u>WhichKey ','<CR>
set timeoutlen=500

It seems like that at the time .vimrc is executed, the plugin is not yet loaded? Any hints?

@liuchengxu
Copy link
Owner

let mapleader=","

let g:which_key_map = {}

autocmd VimEnter * call which_key#register(',', "g:which_key_map")

nnoremap <silent> <leader> :<c-u>WhichKey ','<CR>
vnoremap <silent> <leader> :<c-u>WhichKey ','<CR>

set timeoutlen=500

@dubst3pp4
Copy link
Author

Thanks for your help!

@zhangweiii
Copy link

以下是我的配置文件

" Specify a directory for plugins
" - For Neovim: stdpath('data') . '/plugged'
" - Avoid using standard Vim directory names like 'plugin'
call plug#begin('~/.vim/plugged')
" 按键菜单
Plug 'liuchengxu/vim-which-key', { 'on': ['WhichKey', 'WhichKey!'] }
 
" Unmanaged plugin (manually installed and updated)
" Plug '~/my-prototype-plugin'
 
" Initialize plugin system
call plug#end()
 
" 设置菜单热键
let mapleader=","
 
let g:which_key_map = {}
 
autocmd VimEnter * call which_key#register(',', "g:which_key_map")
 
nnoremap <silent> <leader> :<c-u>WhichKey ','<CR>
vnoremap <silent> <leader> :<c-u>WhichKey ','<CR>
 
set timeoutlen=500

启动时候会报如下错误:

Error detected while processing VimEnter Autocommands for "*":
E117: Unknown function: which_key#register
Press ENTER or type command to continue

请问我哪里弄错了吗?

最开始是按照使用文档写的

" Specify a directory for plugins
" - For Neovim: stdpath('data') . '/plugged'
" - Avoid using standard Vim directory names like 'plugin'
call plug#begin('~/.vim/plugged')
" 按键菜单
Plug 'liuchengxu/vim-which-key', { 'on': ['WhichKey', 'WhichKey!'] }

" Unmanaged plugin (manually installed and updated)
" Plug '~/my-prototype-plugin'

" Initialize plugin system
call plug#end()

" 设置菜单热键
let mapleader=","

call which_key#register(',', "g:which_key_map")

let g:which_key_map = {}

nnoremap <silent> <leader> :<c-u>WhichKey ','<CR>
vnoremap <silent> <leader> :<c-u>WhichKey ','<CR>

set timeoutlen=500

然后报这个错误

Error detected while processing /home/zhangweiii/.config/nvim/init.vim:
line   17:
E117: Unknown function: which_key#register
Press ENTER or type command to continue

@liuchengxu
Copy link
Owner

liuchengxu commented Dec 4, 2019

If you don't know how to use the lazy load feature of vim-plug, then do not use it. Take a closer look at the README of vim-which-key and vim-plug.

The correct lazy load version:

Plug 'liuchengxu/vim-which-key', { 'on': ['WhichKey', 'WhichKey!'] }
autocmd! User vim-which-key call which_key#register(',', 'g:which_key_map')

@zhangweiii
Copy link

嗯嗯,谢谢

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

No branches or pull requests

3 participants