yalay / vim

Automatically exported from code.google.com/p/vim
0 stars 0 forks source link

syntax/tex.vim does not track braces inside \ensuremath{} blocks #321

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. open vim 
2. type ":setf tex"
3. type 
\ensuremath{
    \frac{r_b}{r_a}
}

What is the expected output?
The entire block should have math highlighting.

What do you see instead?
The math highlighting stops after the first }.

What version of the product are you using? On what operating system?
vim 7.4.580, archlinux

Please provide any additional information below.
Clearly the problem is that syntax/tex.vim line 469, which reads

  syn region texMathZoneZ   matchgroup=texStatement start="\\ensuremath\s*{"    matchgroup=texStatement end="}" end="%stopzone\>"   contains=@texMathZoneGroup

does not track all of the braces inside the \ensuremath{} block, so the block 
ends at the first close brace it sees. I don't know how to fix it, though.

Original issue reported on code.google.com by ewtoo...@gmail.com on 22 Jan 2015 at 5:39

GoogleCodeExporter commented 9 years ago
I just found a way to fix this problem! After some vimming, I found replacing 
line 469 with the following lines sufficient to fix this problem!

  syn region texMathZoneZext    start="{"   end="}" transparent contained
  syn region texMathZoneZ   matchgroup=texStatement start="\\ensuremath\s*{"    matchgroup=texStatement end="}" end="%stopzone\>"   contains=@texMathZoneGroup,texMathZoneZext

Original comment by ewtoo...@gmail.com on 22 Jan 2015 at 7:14

GoogleCodeExporter commented 9 years ago
Please try syntax/tex.vim v84 from my website: 
http://www.drchip.org/astronaut/vim/index.html#SYNTAX_TEX

Original comment by drc...@campbellfamily.biz on 22 Jan 2015 at 9:36

GoogleCodeExporter commented 9 years ago
Thanks, Dr. Chip. Your update does indeed fix the brace tracking issue, but it 
also changes highlighting elsewhere. Underscores have changed colour from 
orange to magenta. I don't know if this was intentional or not. On the other 
hand, though, it did fix a different error I hadn't even seen until now. In the 
old version, the following

\begin{equation}
    \frac{r_a}{r_b}
\end{equation}

displays a in orange and b in magenta. They're both magenta now.

Original comment by ewtoo...@gmail.com on 23 Jan 2015 at 6:21

GoogleCodeExporter commented 9 years ago
I just checked again, and v.84 isn't working. I'd forgotten to prevent loading 
of my .vimrc last time using -u NONE. I'm getting the same error as I got when 
I started now. The first closing brace terminates the \ensuremath{} expression.

Original comment by ewtoo...@gmail.com on 13 Apr 2015 at 5:23

GoogleCodeExporter commented 9 years ago
Please try v85 of syntax/tex.vim from my website: 
http://www.drchip.org/astronaut/vim/index.html#SYTNAX_TEX

Original comment by drc...@campbellfamily.biz on 15 Apr 2015 at 2:49