luochen1990 / rainbow

Rainbow Parentheses Improved, shorter code, no level limit, smooth and fast, powerful configuration.
Apache License 2.0
1.78k stars 95 forks source link

double :RainbowToggleOff triggers error #100

Closed gagbo closed 6 years ago

gagbo commented 6 years ago

Describe the bug

Calling rainbow#clear() if there is no active rainbow seems to trigger error

To Reproduce

Expected behavior

Nothing happens, since there is no rainbow higlight

Screenshots

Sorry for the french error message, I'm trying to translate on the fly :

Error detected handling function rainbow_main#clear :                                       
line    1 :                                                                                    
E121: Undefined variable: b:rainbow_confs                                                       
E15: Invalid expression : b:rainbow_confs                                                      
line    5 :                                                                                    
E108: Non-existing variable : b:rainbow_confs                                                    
Hit Enter or enter a command to continue

Additional context

Calling RainbowToggleOff twice might seem dumb, but there's a filetype for which I don't want to have highlights, so I added an autocommand to call RainbowToggleOff (in after/ftplugin/xxx.vim I think), and I trigger this error whenever I come back to a buffer with the given filetype for the second time in a session.

luochen1990 commented 6 years ago

Thanks for your feedback, I will fix this soon. But I think you can solve your problem by configuration (which will be more effective) instead of autocmd, like following (replace coq to the filetype you want to disable):

let g:rainbow_conf = {
\   'separately': {
\       'coq': 0,
\   }
\}