VIM Rainbow Parenthese autostart

送分小仙女□ 提交于 2019-12-11 14:53:07

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!