问题
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
" }
回答1:
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>
" }
来源:https://stackoverflow.com/questions/17387463/vim-rainbow-parenthese-autostart