diff --git a/indent/tex.vim b/indent/tex.vim index b7881aa..1c9d46a 100644 --- a/indent/tex.vim +++ b/indent/tex.vim @@ -88,6 +88,14 @@ function! VimtexIndent() " {{{1 endif endif + " Add/Subtract indent on begin/end displayed equation + if pline =~# '\\\[\s*$' + let ind = ind + &sw + endif + if pline =~# '\\\]\s*$' + let ind = ind - &sw + endif + " Indent opening and closing delimiters let l:delimiters = match(map(synstack(v:lnum, max([col('.') - 1, 1])), \ 'synIDattr(v:val, ''name'')'), '^texMathZone') >= 0 @@ -144,15 +152,11 @@ let s:delimiters_open_tex = '\(' . join([ \ '{', \ '\[', \ '\\(', - \ '\\\[', - \ '\\\Cbegin\s*{.\{-}}', \ ], '\|') . '\)' let s:delimiters_close_tex = '\(' . join([ \ '}', \ '\]', \ '\\)', - \ '\\\]', - \ '\\\Cend\s*{.\{-}}', \ ], '\|') . '\)' let s:delimiters_open_math = '\(' . join([ \ '\\{', diff --git a/test/feature/indentation/main.tex b/test/feature/indentation/main.tex index 8ea37a0..2718d44 100644 --- a/test/feature/indentation/main.tex +++ b/test/feature/indentation/main.tex @@ -6,6 +6,10 @@ \tikz \fill[green] rectangle (0.5,0.5); Something about something. +\[ + 1+1 +\] + \begin{align} 2+2=4 \end{align} @@ -16,10 +20,11 @@ about something. \end{itemize} \begin{equation} - \left\{ - asdasd - \right\} + \left. + f(x) = 3 + \right. \end{equation} + { asdasd }