lervag / vimtex

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

Indentation left/right #3023

Closed switzel closed 1 week ago

switzel commented 1 week ago

Description

I'm 90% sure that this is within the responsibility of vimtex, if not please tell me.

When I autoindent (=) a (la)tex file involving $\left. \right|$ the following lines pick up an extra indentation. The left symbol can be replaced by other things but apparently the \right| does not "close" it.

Steps to reproduce

Put the code

noindent
$\left. \right|$
indent

into a file minimal.tex. Type gg=G. It gets indented as

noindent
$\left. \right|$
  indent

(actually it is indented already while typing). (Github won't let me upload a .tex file.)

Expected behavior

The expected indentation is

noindent
$\left. \right|$
indent

Actual behavior

The indentation vimtex produces is

noindent
$\left. \right|$
  indent

Do you use a latexmkrc file?

No

VimtexInfo

System info
  OS: Ubuntu 20.04.3 LTS
  Vim version: VIM 8.2 (1-16, 647, 17-579, 1969, 580-647, 678, 648-1848, 4975, 5016, 5023, 5072, 2068, 1849-1854, 1857, 1855-1857, 1331, 1858, 1858-1859, 1873, 1860-1969, 1992, 1970-1992, 2010, 1993-2068, 2106, 2069-2106, 2108, 2107-2109, 2109-3995, 4563, 4646, 4774, 4895, 4899, 4901, 4919, 213, 1840, 1846-1847, 2110-2112, 2121)
  Has clientserver: true
  Servername: GVIM

VimTeX project: minimal
  base: minimal.tex
  root: /home/switzel/
  tex: /home/switzel/minimal.tex
  main parser: current file
  document class: 
  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 1 week ago

First, a friendly warning: You are using an old Ubuntu on which the Vim version is also old. I am quite close to only supporting Vim version 9.1.

I'm 90% sure that this is within the responsibility of vimtex, if not please tell me.

When I autoindent (=) a (la)tex file involving | the following lines pick up an extra indentation. The left symbol can be replaced by other things but apparently the \right| does not "close" it.

The problem is that the bar symbol | is very hard to match and that it is not really suitable for use as a delimiter. In your case, it will work if you instead use the \rvert, and this is the proper solution here. See e.g. this tex.stackexchange.com question where the answer should be elucidating.