无聊装了个neocomplcache试下,初步用下来感觉效果的确不错,不过要和 snipMate superTab zencoding插件和谐共存还是要设置一下。。。
首先如果你不需要让他自动启用 (不加 let g:NeoComplCache_EnableAtStartup = 1),或者不需要让他自动弹出提示 (加了 let g:NeoComplCache_DisableAutoComplete = 1),那似乎就不用设置什么了。
如果用了 zencoding.vim,那么vimrc里面不要有 let g:use_zen_complete_tag = 1 ,如果加了这句会使NeoComplCache自动启用那句没做用。。。
另外如果要 snipMate 和 superTab的话,也要修改下,因为snipMate为了与superTab兼容,在提示菜单弹出的时候是不会展开的,即使你修改了触发snipMate的热键也没用,他只会执行superTab的动作。。。
所以我就想把snipMate为了兼容superTab的代码去掉。
打开 ~/.vim/plugin/snipMate.vim 134行开始
134 135 136 137 138 139 140 | if pumvisible() if exists('SuperTabKey') call feedkeys(SuperTabKey) | return '' endif call feedkeys("\<esc>a", 'n') call feedkeys("\<tab>") | return '' endif |
---------------- 2010-08-22 更新 --------------
根据snipMate在github中的最新代码,从149行,开始,从新调整一下TriggerSnippet函数,并且下面再增加一个小函数
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | fun! TriggerSnippet() if exists('g:SuperTabMappingForward') if g:SuperTabMappingForward == "<tab>" let SuperTabKey = "\<c-n>" elseif g:SuperTabMappingBackward == "<tab>" let SuperTabKey = "\<c-p>" endif endif if exists('g:snipPos') | return snipMate#jumpTabStop(0) | endif let word = matchstr(getline('.'), '\S\+\%'.col('.').'c') for scope in [bufnr('%')] + split(&ft, '\.') + ['_'] let [trigger, snippet] = s:GetSnippet(word, scope) " If word is a trigger for a snippet, delete the trigger & expand " the snippet. if snippet != '' if exists('g:loaded_neocomplcache') let g:neocomplcache_disable_auto_complete = 1 inoremap <ESC> <ESC>:call SetNeocomplBack()<CR> snoremap <ESC> <ESC>:call SetNeocomplBack()<CR> endif let col = col('.') - len(trigger) sil exe 's/\V'.escape(trigger, '/\.').'\%#//' return snipMate#expandSnip(snippet, col) endif endfor if exists('SuperTabKey') call feedkeys(SuperTabKey) return '' endif return "\<tab>" endf fun! SetNeocomplBack() let g:neocomplcache_disable_auto_complete = 0 inoremap <ESC> <ESC> snoremap <ESC> <ESC> endf |
-----------------------------------------------
这几句注释掉后就行了,不管是否兼容了,反正用了NeoComplCache自动提示,superTab的作用也体现不出多少了,主要是为了可以用tab键来选择提示菜单中的项目。
还有个办法不需要修改snipMate的代码就是修改superTab的热键,但是如果改掉的话那还能叫superTab不? 哈哈
这里也有个参考,不过他是把NeoComplCache的自动提示关闭了。
http://sinolog.it/?p=1399



