VIM Rainbow Parenthese自动启动(VIM Rainbow Parenthese autostart)

编程入门 行业动态 更新时间:2024-10-26 08:31:44
VIM Rainbow Parenthese自动启动(VIM Rainbow Parenthese autostart)

我正在使用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> " }

更多推荐

本文发布于:2023-07-22 18:22:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1222289.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:自动启动   Rainbow   VIM   autostart   Parenthese

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!