diff --git a/autoload/vimtex/options.vim b/autoload/vimtex/options.vim index 1285136c29c..9d568361801 100644 --- a/autoload/vimtex/options.vim +++ b/autoload/vimtex/options.vim @@ -278,6 +278,7 @@ function! vimtex#options#init() abort " {{{1 \ 'math_fracs': g:vimtex_syntax_conceal_default, \ 'math_super_sub': g:vimtex_syntax_conceal_default, \ 'math_symbols': g:vimtex_syntax_conceal_default, + \ 'sections': g:vimtex_syntax_conceal_default, \ 'styles': g:vimtex_syntax_conceal_default, \}) call s:init_option('vimtex_syntax_conceal_cites', { diff --git a/autoload/vimtex/syntax/core.vim b/autoload/vimtex/syntax/core.vim index 0d6e5408e13..1005a93d9d6 100644 --- a/autoload/vimtex/syntax/core.vim +++ b/autoload/vimtex/syntax/core.vim @@ -470,6 +470,11 @@ function! vimtex#syntax#core#init() abort " {{{1 if g:vimtex_syntax_conceal.cites call s:match_conceal_cites_{g:vimtex_syntax_conceal_cites.type}() endif + + " Conceal section commands + if g:vimtex_syntax_conceal.sections + call s:match_conceal_sections() + endif endif " }}}2 @@ -596,6 +601,7 @@ function! vimtex#syntax#core#init_highlights() abort " {{{1 highlight def link texNewenvOpt texOpt highlight def link texNewenvParm texParm highlight def link texOptEqual texSymbol + highlight def link texPartConcealed texCmdPart highlight def link texRefOpt texOpt highlight def link texRefConcealedOpt1 texRefOpt highlight def link texRefConcealedOpt2 texRefOpt @@ -1548,3 +1554,15 @@ function! s:match_conceal_cites_icon() abort " {{{1 endfunction " }}}1 +function! s:match_conceal_sections() abort " {{{1 + syntax match texCmdPart "\v\\%(sub)*section>\*?" contains=texPartConcealed nextgroup=texPartArgTitle + syntax match texPartConcealed "\\" contained conceal cchar=# + syntax match texPartConcealed "sub" contained conceal cchar=# + syntax match texPartConcealed "section" contained conceal cchar= + + call vimtex#syntax#core#new_arg('texPartArgTitle', { + \ 'opts': 'contained keepend concealends' + \}) +endfunction + +" }}}1 diff --git a/doc/vimtex.txt b/doc/vimtex.txt index dfc9cd6d302..e3edf0452cf 100644 --- a/doc/vimtex.txt +++ b/doc/vimtex.txt @@ -2076,6 +2076,9 @@ OPTIONS *vimtex-options* Replace various math symbol commands to an equivalent unicode character. This includes quite a lot of replacements, so be warned! + sections~ + Conceal `\(sub)*section` commands. + styles~ Conceal the LaTeX command "boundaries" for italized and bolded style commands, i.e. `\emph`, `\textit`, and `\textbf`. This means that one diff --git a/test/test-syntax/test-conceal.tex b/test/test-syntax/test-conceal.tex index 2643665ad07..93dacaf5f88 100644 --- a/test/test-syntax/test-conceal.tex +++ b/test/test-syntax/test-conceal.tex @@ -35,4 +35,12 @@ $4 \mathit{x} = \mathbf{test}$ $\mathrm{Re} = \cdots$ +\chapter{test} + +\section{test} + +\subsection{testing} + +\subsubsection{testing} + \end{document}