luochen1990 / rainbow

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

Compatibility with vimtex #142

Open gvdeynde opened 4 years ago

gvdeynde commented 4 years ago

Hi Anybody any tips to get rainbow parentheses working with lervag/vimtex (https://github.com/lervag/vimtex)? It seems that the syntax definitions in vimtex mess up colored parenthesis (if I manually switch syntax to 'plaintex' they appear again).

Thanks Gert

lervag commented 4 years ago

As far as I can tell, vimtex should work just fine with rainbow parantheses (see https://github.com/lervag/vimtex/issues/1672).

lervag commented 4 years ago

Ok, sorry, new development: As can be seen in this minimal example:

" test.vim
set nocompatible
let &runtimepath = '~/.vim/bundle/rainbow,' . &runtimepath
filetype plugin on
syntax enable

let g:rainbow_active = 1
% test.tex
\documentclass{minimal}
\begin{document}

Hello World! (((()))) {{{{{}}}}}

\section*{Test}

Hello World! ((())) {{{}}}

\end{document}

With nvim -u test.vim test.tex (or vim -u test.vim test.tex), we now see that the first set of parantheses has rainbow colors, but none of the other sets. This is independent of vimtex and seems to be caused by the tex syntax plugin that adds a "top layer" syntax such that the rainbox syntax elements would need to be added to the tex syntax clusters in order to work. Not sure if this is something @luochen would be willing to do.

yushangakki commented 2 years ago

Is there anyway to make the parentheses rainbowish in side math delimeters?

iChunyu commented 2 years ago

Hello everyone, I've met the same issue. The rainbow works well in common text, but fails in math environment. The most strange thing is that it works again in a standalone *ed environment, which is usually used as a sub-environment.

rainbow

The relevant configurations are:

let g:rainbow_active = 1
let g:rainbow_conf = {
    \   'guifgs': ['#2D85F0','#F4433C','#FFBC32','#0AA858','#B845FF','#FB7299','#8C564B','#7F7F7F','#8DA0CB'],
    \   'separately': {
    \       'tex':{
    \           'parentheses': ['start=/(/ end=/)/ fold', 'start=/\[/ end=/\]/ fold', 'start=/{/ end=/}/ fold',
    \                           'start=/\\left[\(\[\{\.]/ end=/\\right[\)\]\}\.]/ fold',
    \                           'start=/\\[bB]igl[\(\[\{\.]/ end=/\\[bB]igr[\)\]\}\.]/ fold',
    \                           'start=/\\[bB]iggl[\(\[\{\.]/ end=/\\[bB]iggr[\)\]\}\.]/ fold'],
    \       }
    \   }
    \ }
lervag commented 2 years ago

I believe the issue is that the rainbow paranthesis syntax groups (or the outer group) must be added to the math region clusters. I'm not sure if this should be done by the rainbow plugin itself. It might be better to do it as a personal customization. I'll leave it to luochen to respond.

luochen1990 commented 2 years ago

I believe the issue is that the rainbow paranthesis syntax groups (or the outer group) must be added to the math region clusters. I'm not sure if this should be done by the rainbow plugin itself. It might be better to do it as a personal customization. I'll leave it to luochen to respond.

There is manual about this mechanism: :h :syn-containedin , You can also use this mechanism in this plugin as parentheses_options: "containedin=xxx"