rainbow icon indicating copy to clipboard operation
rainbow copied to clipboard

Compatibility with vimtex

Open gvdeynde opened this issue 4 years ago • 6 comments

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

gvdeynde avatar Apr 06 '20 11:04 gvdeynde

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

lervag avatar Apr 21 '20 20:04 lervag

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.

lervag avatar Apr 22 '20 09:04 lervag

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

yushangakki avatar Aug 10 '21 05:08 yushangakki

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'],
    \       }
    \   }
    \ }

iChunyu avatar Jun 03 '22 10:06 iChunyu

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.

lervag avatar Jun 03 '22 10:06 lervag

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"

luochen1990 avatar Jun 06 '22 06:06 luochen1990