rainbow icon indicating copy to clipboard operation
rainbow copied to clipboard

Not working with ft=tex

Open mreppen opened this issue 6 years ago • 11 comments

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

screenshot_20180814_174000

Notes

It works for the same document when changing ft: set ft=text

Related issue? https://github.com/junegunn/rainbow_parentheses.vim/issues/10

mreppen avatar Aug 14 '18 15:08 mreppen

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.

luochen1990 avatar Aug 15 '18 02:08 luochen1990

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

screenshot_20180815_094803

mreppen avatar Aug 15 '18 07:08 mreppen

@mreppen did you ever figure this out? I'm experiencing the same problem.

bisraelsen avatar Jan 15 '19 17:01 bisraelsen

@bisraelsen Unfortunately not. My understanding of the deeper workings of vim is too shallow to really try anything useful.

mreppen avatar Jan 15 '19 19:01 mreppen

pushed a fixup, anybody help to make sure it is correct ?

luochen1990 avatar Jan 16 '19 03:01 luochen1990

Thanks, that gives a bit more color. However, in the "texMathZone?" regions it does not work:

screenshot_20190116_104207

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?

mreppen avatar Jan 16 '19 15:01 mreppen

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?

luochen1990 avatar Jan 17 '19 05:01 luochen1990

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.

bisraelsen avatar Jan 28 '19 17:01 bisraelsen

I will write a pull request with containedins 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.

mreppen avatar Jan 28 '19 17:01 mreppen

There are some cases of curly braces that I cannot make work. For instance, in the case of this figure screenshot_20190211_154209

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?

mreppen avatar Feb 11 '19 20:02 mreppen

Is there a self-contained example which I can use to reproduce your problem?

luochen1990 avatar Feb 12 '19 09:02 luochen1990