rainbow
rainbow copied to clipboard
Not working with ft=tex
Describe the bug
In TeX documents, the plugin is not working inside
\begin{document}
...
\end{document
To Reproduce
init.vim/vimrc:
call plug#begin('~/.local/share/nvim/plugged')
Plug 'luochen1990/rainbow'
call plug#end()
set nocompatible
let g:rainbow_active = 1
let g:rainbow_conf = {
\ 'separately': {
\ '*': {},
\ 'tex': {
\ 'parentheses': ['start=/(/ end=/)/', 'start=/\[/ end=/\]/', 'start=/{/ end=/}/'],
\ },
\ },
\}
Example document:
\documentclass[]{article}
{{{{}}}}
((((((()))))))
[[[[[[]]]]]]
\begin{document}
((((()))))
${{{{}}}}$
{{{{}}}}
[[[[[[]]]]]]
\end{document}
Expected behavior
For the colors to appear equally inside and outside the document
environment.
Screenshots
Notes
It works for the same document when changing ft: set ft=text
Related issue? https://github.com/junegunn/rainbow_parentheses.vim/issues/10
Is there some special reason which makes you specify separately.tex.parentheses
by yourself? Because in the default configuration, {}
is not included in separately.tex.parentheses
.
The curly braces are the most important to me, but the same problem is there without:
Here is an updated version: init.vim/vimrc:
call plug#begin('~/.local/share/nvim/plugged')
Plug 'luochen1990/rainbow'
call plug#end()
set nocompatible
let g:rainbow_active = 1
@mreppen did you ever figure this out? I'm experiencing the same problem.
@bisraelsen Unfortunately not. My understanding of the deeper workings of vim is too shallow to really try anything useful.
pushed a fixup, anybody help to make sure it is correct ?
Thanks, that gives a bit more color. However, in the "texMathZone?" regions it does not work:
Running echo join(reverse(map(synstack(line('.'), col('.')), 'synIDattr(v:val,"name")')),' ')
gives texMathZoneX texDocZone
inside $...$
and texMathZoneW texDocZone
in \[...\]
. There are apparently also versions with V
and Y
.
Manually adding these (and possibly other) cases works, but it would be more elegant if the containedin=texDocZone
were sufficient. Do you think that is possible?
I'm not very familiar with tex's syntax, can you provide a list of containedin
names along with a test file for what you want? or a pull request?
I guess that the basic idea is that math equations are contained either within single dollar signs $x=y^{z+2}+(z+0.5)$
or in double dollar signs $$x=y^{z+2}+(z+0.5)$$
. There is a third way to enclose math that is shown above: \[ x=y^{z+2}+(z+0.5) \]
Basically anything within $ $
, $$ $$
, or \[ \]
is mathematics and should have matching braces matched. For that matter, even the $ $
and \[ \]
enclose things and I guess could also theoretically be colored for matches as well.
I will write a pull request with containedin
s for all delimiters I find relevant in TeX. It will need some testing on different documents, but I should find time one of the coming days.
There are some cases of curly braces that I cannot make work. For instance, in the case of this figure
It seems like the rainbow zones are not loaded for the first case regardless of what containedin=...
I enter.
@luochen1990 Do you have any clue?
Is there a self-contained example which I can use to reproduce your problem?