Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim Folding with RainbowParentheses

Tags:

c++

vim

So, I've looked everywhere for a good rainbow parentheses plugin that will give different level parentheses different colors. I really like the couple that I've found, because they both do a good job of customizability while highlighting the right thing. It supports more than parentheses; chevrons, braces and brackets all get highlighted, which I really like.

It seems like there are quite a few plugins for this!; I'm currently using oblitum's because his is optimized for dark backgrounds (I often work straight from the shell).

So, following the tip at the github for that plugin, I have the "always on" snippet in my .vimrc. But when the always on block is above "syntax enable" it doesn't show {} as being highlighted for cpp files. When the always on block is below syntax enable, folding doesn't work. I think its the nature of the plugin that makes it do this; it goes though the file and adds coloration information. I notice that if I use the command :syntax enable after I've loaded the file when its not recognizing folds, then it does recognize the folds. But at this point, it removes the coloration that rainbow parentheses put on it.

In my .vimrc, I have the follow pertinent lines:

syntax enable
set foldmethod=syntax
set foldenable
set foldlevel=100

let g:rainbow_operators=2
au FileType c,cpp,objc,objcpp call rainbow#activate()

I think that, from looking at syntax files that come with vim, such as c.vim, you can see that certain blocks are annotated as folding. I bet that if you could just write a regex based upon it, you could identify characters as syntactic groups. Then you could just define a colorscheme for it. In fact, the rainbow plugin is actually calling "syn region" commands, so I think that this route is very doable, I'm just not that knowledgable with vim scripting.

Can anybody help me modify possibly the plugin or come up with a script or something that achieves both?

like image 524
Adam Miller Avatar asked Nov 03 '22 04:11

Adam Miller


1 Answers

Sorry the lateness, I've tried to solve it at Fix disabled folding (issue #2)

like image 68
pepper_chico Avatar answered Nov 15 '22 06:11

pepper_chico