junegunn / rainbow_parentheses.vim

:rainbow: Simpler Rainbow Parentheses
377 stars 24 forks source link

Rainbow Parentheses disables folding in c #11

Closed systemmonkey42 closed 8 years ago

systemmonkey42 commented 8 years ago

I do a ton of C development, and use folding fairly heavily.

When your rainbow_parentheses plugin is enable, vim report 'no fold found' when attempting to fold code.

It appears that the regions which are created using

`let cmd = 'syntax region rainbowParens%d matchgroup=rainbowParensShell%d start=/%s/ end=/%s/ contains=%s'`

simply override the regions defined in the syntax file;

`syn region cBlock      start="{" end="}" transparent fold`

Adding 'fold' to the end of the region command appears to have fixed this for now, but its a pretty naive solution.

junegunn commented 8 years ago

Thanks for the heads up. I use this plugin only for lisps and I don't really use folds, so I haven't run into the situation yet and not sure what would be the right solution. I just opened a C file and I can't seem to reproduce the issue.

screen shot 2016-05-17 at 12 38 43 am
systemmonkey42 commented 8 years ago

My apologies. I have this in my vimrc

    autocmd FileType vim,c,cpp let g:rainbow#pairs = [['(', ')'], ['[', ']'], ['{', '}']] | RainbowParentheses

The pair of curly braces at the end are the ones which broke c/c++ folding. If you use the default config, it doesn't override the curly braces, and doesn't break folding.

Unfortunately I've gotten to like being able to align my braces by color :-)

I will keep using a fork'd copy of rainbowparenthes with the added 'fold' option until I can suggest a better way, especially some way of detecting fold setting in existing syntax rules.

junegunn commented 8 years ago

Cool.

toejough commented 4 years ago

This is breaking vim-go's syntax folding as well. Unfortunately, vim-go folds on raw parens in some cases, too, so even with the default rainbow settings the folds are all messed up for .go files. :-/

I don't know enough vim-fu to propose a solution, either, but folding is of much higher utility for me than rainbow parens, so I'm going to stop using this plugin.

I must say, though, that I've appreciated it a great deal when working with other languages - thank you for providing it!