Skip to content

[RFC] Further concealments: math matrices & envs, alignment character, conceal first space after left delimiter word e.g. \langle #2645

@kiryph

Description

@kiryph

I am evaluating the concealment feature how much I would conceal to increase the readability:

I am trying following:

  1. Math matrices
  2. Math environments \begin{equation|...} and end{equation|...}
  3. Alignment character &
  4. First space after left delimiter word e.g. \langle
" Amsmath Matrices
" \begin{Vmatrix|vmatrix|Bmatrix|bmatrix|matrix|pmatrix|smallmatrix} \end{...}
syntax match texCmdEnvM "\\begin{Vmatrix}"     contained conceal cchar=
syntax match texCmdEnvM "\\end{Vmatrix}"       contained conceal cchar=
syntax match texCmdEnvM "\\begin{vmatrix}"     contained conceal cchar=|
syntax match texCmdEnvM "\\end{vmatrix}"       contained conceal cchar=|
syntax match texCmdEnvM "\\begin{Bmatrix}"     contained conceal cchar={
syntax match texCmdEnvM "\\end{Bmatrix}"       contained conceal cchar=}
syntax match texCmdEnvM "\\begin{bmatrix}"     contained conceal cchar=[
syntax match texCmdEnvM "\\end{bmatrix}"       contained conceal cchar=]
syntax match texCmdEnvM "\\begin{pmatrix}"     contained conceal cchar=(
syntax match texCmdEnvM "\\end{pmatrix}"       contained conceal cchar=)
syntax match texCmdEnvM "\\begin{smallmatrix}" contained conceal cchar=(
syntax match texCmdEnvM "\\end{smallmatrix}"   contained conceal cchar=)
syntax match texCmdEnvM "\\begin{matrix}"      contained conceal
syntax match texCmdEnvM "\\end{matrix}"        contained conceal

" Hide Array
syntax match texMathCmdEnv "\\begin{array}{.\{-}}" contained conceal
syntax match texMathCmdEnv "\\end{array}"          contained conceal

" Hide math environments similar to \[ \]
syntax match texMathEnvBgnEnd "\\begin{equation\*\?}" contained conceal
syntax match texMathEnvBgnEnd "\\end{equation\*\?}"   contained conceal
syntax match texMathEnvBgnEnd "\\begin{align\*\?}"    contained conceal
syntax match texMathEnvBgnEnd "\\end{align\*\?}"      contained conceal
syntax match texMathEnvBgnEnd "\\begin{gather\*\?}"   contained conceal
syntax match texMathEnvBgnEnd "\\end{gather\*\?}"     contained conceal
syntax match texMathEnvBgnEnd "\\begin{aligned\*\?}"  contained conceal
syntax match texMathEnvBgnEnd "\\end{aligned\*\?}"    contained conceal

syntax match texCmdEnvM "\\begin{alignat\*\?}{.\{-}}" contained conceal
syntax match texCmdEnvM "\\end{alignat\*\?}"          contained conceal

syntax match texCmdEnvM "\\begin{empheq\*\?}\(\[.\{-}\]\)\?{.\{-}}" contained conceal
syntax match texCmdEnvM "\\end{empheq\*\?}"                         contained conceal

" Conceal alignment character
syntax match texTabularChar /&/ conceal
syntax match texTabularChar /&/ contained conceal

For the math enviornments and the alignment character I feel like this should be optional and possibly by default turned off.

Currently, only the concealment for sections as markdown/atx formatting is disabled:

vimtex/doc/vimtex.txt

Lines 2410 to 2424 in b527d75

let g:vimtex_syntax_conceal = {
\ 'accents': 1,
\ 'ligatures': 1,
\ 'cites': 1,
\ 'fancy': 1,
\ 'spacing': 1,
\ 'greek': 1,
\ 'math_bounds': 1,
\ 'math_delimiters': 1,
\ 'math_fracs': 1,
\ 'math_super_sub': 1,
\ 'math_symbols': 1,
\ 'sections': 0,
\ 'styles': 1,
\}

I also have refined the concealment of \langle as following:

" Refined concealment: capture optional space " \?"
syntax match texMathDelim "\\langle\> \?" contained conceal cchar=

To understand the motivation consider this part of an equation:

\forall \{i,j;n_k\} \in E(\langle G,n\rangle)

is now displayed as
Screenshot 2023-02-24 at 13 33 27

and without the refinement it looks like following:
Screenshot 2023-02-24 at 13 34 36

Do you see the additional space after ?

I am not sure about them yet. I guess time will tell. If others consider them also worthwhile, they could express their interest.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions