lervag / vimtex

VimTeX: A modern Vim and neovim filetype plugin for LaTeX files.
MIT License
5.42k stars 389 forks source link

Incorrect syntax highlighting for nested math expressions using \( and \) #2429

Closed pedrominicz closed 2 years ago

pedrominicz commented 2 years ago

Description

Syntax highlighting incorrectly reports an error when using \( and \) to open and close inline math expressions. The issue doesn't happen with $. The issue also exists on the default Neovim config (without VimTeX installed), but installing VimTeX makes the issue worse.

Steps to reproduce

minimal.vim

call plug#begin()
Plug 'lervag/vimtex'
call plug#end()

minimal.tex

\documentclass{article}

\begin{document}

% Issues on this line.
Let \(F = \{f : S \to S \mid \textnormal{\(f\) is a cool function}\}\).

% No issues on this line.
Let \(F = \{f : S \to S \mid \textnormal{$f$ is a cool function}\}\).

\end{document}

Running nvim -u minimal.vim minimal.tex on the release build of Neovim 0.7.2, one can see issues on one of the lines where } and \) are highlighted red despite there being no error. Running nvim -u /dev/null minimal.tex on the same Neovim build, the same line contains wrong syntax highlighting for the last closing \) but not for }.

Expected behavior

No syntax highlighting indicating error: there is no error.

Actual behavior

Syntax highlighting indicating error.

Do you use a latexmkrc file?

No.

VimtexInfo

System info:
  OS: Linux 5.18.6-arch1-1
  Vim version: NVIM v0.7.2
  Has clientserver: true
  Servername: /tmp/nvimTznxGZ/0

VimTeX project: minimal
  base: minimal.tex
  root: /home/user/tmp/issue
  tex: /home/user/tmp/issue/minimal.tex
  main parser: current file verified
  document class: article
  compiler: latexmk
    engine: -pdf
    options:
      -verbose
      -file-line-error
      -synctex=1
      -interaction=nonstopmode
    callback: 1
    continuous: 1
    executable: latexmk
  viewer: General
  qf method: LaTeX logfile
lervag commented 2 years ago

Confirmed. I see what the issue is, I'll look into it as soon as I have time.