我正在使用rainbow_parentheses插件,我希望它从VIM启动开始。 目前,在启动时,没有任何变化; 在启动后手动调用Load_Rainbow时,它可以正常工作。
相关的vimrc部分如下:
" Rainbow Parentheses options { function! Config_Rainbow() call rainbow_parentheses#load(0) call rainbow_parentheses#load(1) call rainbow_parentheses#load(2) endfunction function! Load_Rainbow() call rainbow_parentheses#activate() endfunction augroup TastetheRainbow autocmd! autocmd Syntax * call Config_Rainbow() autocmd VimEnter * call Load_Rainbow() augroup END " }I'm using the rainbow_parentheses plugin and I'm wishing for it start on VIM start. Currently, on start-up, nothing changes; when Load_Rainbow is called manually after start-up, it works.
The relevant vimrc section is as follows:
" Rainbow Parentheses options { function! Config_Rainbow() call rainbow_parentheses#load(0) call rainbow_parentheses#load(1) call rainbow_parentheses#load(2) endfunction function! Load_Rainbow() call rainbow_parentheses#activate() endfunction augroup TastetheRainbow autocmd! autocmd Syntax * call Config_Rainbow() autocmd VimEnter * call Load_Rainbow() augroup END " }最满意答案
正如上面的FDinoff检查的那样,这个问题看起来是特定于平台的:Win 64bit,用这里和这里的二进制文件进行测试。 在32位gVim中测试这些设置时确认了这一点。 我仍然不确定确切的根本原因,但是我发现了一个解决方法。 我认为问题是Syntax和VimEnter autocmd事件的排序,因此解决方案是在Syntax事件期间设置VimEnter autocmd。
vimrc文件中:
" Rainbow Parentheses options { function! Config_Rainbow() call rainbow_parentheses#load(0) " Load Round brackets call rainbow_parentheses#load(1) " Load Square brackets call rainbow_parentheses#load(2) " Load Braces autocmd! TastetheRainbow VimEnter * call Load_Rainbow() " 64bit Hack - Set VimEnter after syntax load endfunction function! Load_Rainbow() call rainbow_parentheses#activate() endfunction augroup TastetheRainbow autocmd! autocmd Syntax * call Config_Rainbow() " Load rainbow_parentheses on syntax load autocmd VimEnter * call Load_Rainbow() augroup END " rainbow_parentheses toggle nnoremap <silent> <Leader>t :call rainbow_parentheses#toggle()<CR> " }As checked by FDinoff above, this issue appears to be platform specific: Win 64bit, as tested with the binaries from here and here. This was confirmed when testing those settings in a 32bit gVim. I'm still unsure of the exact root cause, however I have discovered a work-around. I think the problem is the ordering of the Syntax and VimEnter autocmd events, so the solution is to set the VimEnter autocmd during the Syntax event.
vimrc:
" Rainbow Parentheses options { function! Config_Rainbow() call rainbow_parentheses#load(0) " Load Round brackets call rainbow_parentheses#load(1) " Load Square brackets call rainbow_parentheses#load(2) " Load Braces autocmd! TastetheRainbow VimEnter * call Load_Rainbow() " 64bit Hack - Set VimEnter after syntax load endfunction function! Load_Rainbow() call rainbow_parentheses#activate() endfunction augroup TastetheRainbow autocmd! autocmd Syntax * call Config_Rainbow() " Load rainbow_parentheses on syntax load autocmd VimEnter * call Load_Rainbow() augroup END " rainbow_parentheses toggle nnoremap <silent> <Leader>t :call rainbow_parentheses#toggle()<CR> " }更多推荐
发布评论