liuchengxu / vim-which-key

:tulip: Vim plugin that shows keybindings in popup
https://liuchengxu.github.io/vim-which-key/
MIT License
1.93k stars 66 forks source link

注册函数启动时出错 #26

Closed InactionEver closed 5 years ago

InactionEver commented 5 years ago

call which_key#register('', "g:which_key_map") image 这个函数,在打开gvim的时候会出现如图所示的错误。但是打开后在手动运行这个函数可以。

以下是代码: Plug 'liuchengxu/vim-which-key' set timeoutlen=500 let g:mapleader = "\" let g:maplocalleader = ',' " nnoremap :WhichKey '' " nnoremap :WhichKey ','

let g:which_key_map = {}

" name 是一个特殊字段,如果 dict 里面的元素也是一个 dict,那么表明一个 group,比如 +file, 就会高亮和显示 +file 。默认是 +prefix.

" ======================================================= " 基于已经存在的快捷键映射,直接使用一个字符串说明介绍信息即可 " ======================================================= " You can pass a descriptive text to an existing mapping.

let g:which_key_map.f = { 'name' : '+file' }

nnoremap fs :update let g:which_key_map.f.s = 'save-file'

nnoremap fd :e $MYVIMRC let g:which_key_map.f.d = 'open-vimrc'

nnoremap oq :copen nnoremap ol :lopen

let g:which_key_map.o = { \ 'name' : '+open', \ 'q' : 'open-quickfix' , \ 'l' : 'open-locationlist', \ } " ======================================================= " 不存在相关的快捷键映射,需要用一个 list: " 第一个元素表明执行的操作,第二个是该操作的介绍 " ======================================================= " Provide commands(ex-command, // mapping, etc.) and descriptions for existing mappings let g:which_key_map.b = { \ 'name' : '+buffer' , \ '1' : ['b1' , 'buffer 1'] , \ '2' : ['b2' , 'buffer 2'] , \ 'd' : ['bd' , 'delete-buffer'] , \ 'f' : ['bfirst' , 'first-buffer'] , \ 'h' : ['Startify' , 'home-buffer'] , \ 'l' : ['blast' , 'last-buffer'] , \ 'n' : ['bnext' , 'next-buffer'] , \ 'p' : ['bprevious' , 'previous-buffer'] , \ }

call which_key#register('', "g:which_key_map") nnoremap :WhichKey '' vnoremap :WhichKeyVisual ''

liuchengxu commented 5 years ago

Put the configuration stuffs after plug#end().

InactionEver commented 5 years ago

果然可以了,感谢感谢。我把其他的插件配置都放到后面来