Repository: lervag/vimtex

Issue #1099: Syntax highlight error
Created: 2018-04-06T09:43:14Z
Hey, I am seeing an error in the syntax highlighter on the following snippet,
The _ in B_{i+1} is highlighted as a "tex syntax error" (red background for me) here:
\begin{tikzpicture}[scale=0.96]
    \node (org-a-0) at (-2.5, 2.5) {\small{$B_{i-1}$}};
\end{tikzpicture}
And here there's no issue (added \section):
\section
\begin{tikzpicture}[scale=0.96]
    \node (org-a-0) at (-2.5, 2.5) {\small{$B_{i-1}$}};
\end{tikzpicture}
Is this a bug in the highlighter or am I missing something?

Duplicate issue #1457: Syntax highlighting broken after backward syncing
Created: 2019-08-23T13:08:11Z
Issue
Superscripts(^) and subscripts(_), etc. in math environments show up as invalid after backward syncing from zathura.
minimal.vim
set nocompatible
let &runtimepath  = '~/.vim/bundle/vimtex,' . &runtimepath
let &runtimepath .= ',~/.vim/bundle/vimtex/after'
filetype plugin indent on
syntax enable

let g:vimtex_view_method = 'zathura'

if has('nvim')
  let g:vimtex_compiler_progname = 'nvr'
endif

nnoremap q :qall!<cr>
nnoremap e :echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')<cr>

silent edit minimal.tex
minimal.tex
Here is a much simpler file to debug with.
\documentclass[12pt]{article}
\usepackage{amsmath}

\begin{document}

\begin{align*}
  \vec{u} = \begin{bmatrix}
      3\\1
  \end{bmatrix}
\end{align*}

\begin{align*}
  \sigma_{\vec{u}} = \sqrt{\sum_{i=1}^N (u_i - \mu_u)^2}
\end{align*}
\end{document}

Commands/Input

Close any existing zathura windows
nvim -u minivimrc
Run ":VimtexCompile". Wait until zathura pops up.
Ctrl+click on any formula in zathura, and make sure the document in vim correctly is synced to the correct position.
Observe the highlighting of any ^ and _ in align* environment

Observed Behaviour

Expected Behaviour
Probably something similar to this.

Output from VimtexInfo
System info
  OS: Arch Linux
  Vim version: NVIM v0.4.0-1792-gc6eb1f42b
  Has clientserver: true
  Servername: /tmp/nvim

vimtex project: test3
  base: test3.tex
  root: /home/krasjet/tmp/highlight
  tex: /home/krasjet/tmp/highlight/test3.tex
  out: /home/krasjet/tmp/highlight/test3.pdf
  log: /home/krasjet/tmp/highlight/test3.log
  aux: /home/krasjet/tmp/highlight/test3.aux
  fls: /home/krasjet/tmp/highlight/test3.fls
  compiler: latexmk
    backend: nvim
    output: /tmp/nvimJQyUB9/1
    configuration: 
      continuous: 1
      callback: 1
      latexmk options:
        -verbose
        -file-line-error
        -synctex=1
        -interaction=nonstopmode
      latexmk engine: -pdf
    pid: 0
    cmd: max_print_line=2000 latexmk -verbose -file-line-error -synctex=1 -interaction=nonstopmode -pdf -pvc -e '$new_viewer_always = "0"' -e '$pdf_previewer = "zathura  -x \"nvr --servername /tmp/nvim --remote +\%{line} \%{input}\" \%S"' -e '$success_cmd = "echo vimtex_compiler_callback_success"' -e '$failure_cmd = "echo vimtex_compiler_callback_failure"' 'test3.tex'
  viewer: Zathura
    xwin id: 44040195
  qf: LaTeX logfile
    config: 
      packages: 
        default: 1
      default: 1
  document class: article
  packages:
    amsbsy
    amsgen
    amsmath
    amsopn
    amstext

Closing comment (2019-10-21T13:41:51Z): Note: Even if it is related to #1099, please open a new issue. It makes it much easier for me.
Note 2: No reason to use pastebin instead of attaching output inside fenced code blocks (``` ... ```).