Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion autoload/vimtex/compiler.vim
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ endfunction

" {{{1 Initialize module

if !g:vimtex_compiler_enabled | finish | endif
if !get(g:, 'vimtex_compiler_enabled') | finish | endif

augroup vimtex_compiler
autocmd!
Expand Down
35 changes: 22 additions & 13 deletions autoload/vimtex/options.vim
Original file line number Diff line number Diff line change
Expand Up @@ -273,24 +273,25 @@ function! vimtex#options#init() abort " {{{1
call s:init_option('vimtex_subfile_start_local', 0)

call s:init_option('vimtex_syntax_enabled', 1)
call s:init_option('vimtex_syntax_conceal_default', 1)
call s:init_option('vimtex_syntax_conceal', {
\ 'accents': g:vimtex_syntax_conceal_default,
\ 'cites': g:vimtex_syntax_conceal_default,
\ 'fancy': g:vimtex_syntax_conceal_default,
\ 'greek': g:vimtex_syntax_conceal_default,
\ 'math_bounds': g:vimtex_syntax_conceal_default,
\ 'math_delimiters': g:vimtex_syntax_conceal_default,
\ 'math_fracs': g:vimtex_syntax_conceal_default,
\ 'math_super_sub': g:vimtex_syntax_conceal_default,
\ 'math_symbols': g:vimtex_syntax_conceal_default,
\ 'styles': g:vimtex_syntax_conceal_default,
\ 'accents': 1,
\ 'cites': 1,
\ 'fancy': 1,
\ 'greek': 1,
\ 'math_bounds': 1,
\ 'math_delimiters': 1,
\ 'math_fracs': 1,
\ 'math_super_sub': 1,
\ 'math_symbols': 1,
\ 'sections': 0,
\ 'styles': 1,
\})
call s:init_option('vimtex_syntax_conceal_cites', {
\ 'type': 'brackets',
\ 'icon': '📖',
\ 'verbose': v:true,
\})
call s:init_option('vimtex_syntax_conceal_disable', 0)
call s:init_option('vimtex_syntax_custom_cmds', [])
call s:init_option('vimtex_syntax_nested', {
\ 'aliases' : {
Expand Down Expand Up @@ -323,10 +324,17 @@ function! vimtex#options#init() abort " {{{1
call s:init_option('vimtex_syntax_nospell_comments', 0)
call s:init_option('vimtex_syntax_packages', {
\ 'amsmath': {'load': 2},
\ 'babel': {'conceal': g:vimtex_syntax_conceal_default},
\ 'hyperref': {'conceal': g:vimtex_syntax_conceal_default},
\ 'babel': {'conceal': 1},
\ 'hyperref': {'conceal': 1},
\})

" Disable conceals if chosen
if g:vimtex_syntax_conceal_disable
call map(g:vimtex_syntax_conceal, {k, v -> 0})
let g:vimtex_syntax_packages.babel.conceal = 0
let g:vimtex_syntax_packages.hyperref.conceal = 0
endif

call s:init_option('vimtex_texcount_custom_arg', '')

call s:init_option('vimtex_text_obj_enabled', 1)
Expand Down Expand Up @@ -464,6 +472,7 @@ function! s:check_for_deprecated_options() abort " {{{1
\ 'g:vimtex_quickfix_latexlog',
\ 'g:vimtex_quickfix_warnings',
\ 'g:vimtex_syntax_autoload_packages',
\ 'g:vimtex_syntax_conceal_default',
\ 'g:vimtex_textidote_jar',
\ 'g:vimtex_toc_fold',
\ 'g:vimtex_toc_fold_level_start',
Expand Down
19 changes: 19 additions & 0 deletions autoload/vimtex/syntax/core.vim
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,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
Expand Down Expand Up @@ -785,6 +790,8 @@ function! vimtex#syntax#core#init_highlights() abort " {{{1
highlight def link texParboxOptHeight texError
highlight def link texParboxOptIPos texError
highlight def link texParboxOptPos texError
highlight def link texPartConcealed texCmdPart
highlight def link texPartConcArgTitle texPartArgTitle
highlight def link texRefOpt texOpt
highlight def link texRefConcealedOpt1 texRefOpt
highlight def link texRefConcealedOpt2 texRefOpt
Expand Down Expand Up @@ -1927,6 +1934,18 @@ function! s:match_conceal_cites_icon() abort " {{{1
\ 'conceal cchar=' . g:vimtex_syntax_conceal_cites.icon
endfunction

" }}}1
function! s:match_conceal_sections() abort " {{{1
syntax match texCmdPart "\v\\%(sub)*section>\*?" contains=texPartConcealed nextgroup=texPartConcArgTitle
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('texPartConcArgTitle', {
\ 'opts': 'contained keepend concealends'
\})
endfunction

" }}}1

function! s:gather_newtheorems() abort " {{{1
Expand Down
53 changes: 39 additions & 14 deletions doc/vimtex.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2133,13 +2133,6 @@ OPTIONS *vimtex-options*

Default value: 1.

*g:vimtex_syntax_conceal_default*
Specify the default flag for the conceal feature. This is used e.g. in
|vimtex_syntax_conceal| and for package specific options in
|vimtex_syntax_packages|. For more info, see |vimtex-syntax-conceal|.

Default value: 1

*g:vimtex_syntax_conceal*
A dictionary for specifying which core conceal features to activate. This
mostly implies concealing particular elements with a replacement unicode
Expand Down Expand Up @@ -2183,14 +2176,42 @@ 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. The titles are replaced with Markdown
style ATX headers, e.g.:

`\section{Test}` --> `# Test`
`\subsection{Test}` --> `## Test`

styles~
Conceal the LaTeX command "boundaries" for italicized and bolded style
commands, i.e. `\emph`, `\textit`, and `\textbf`. This means that one
will see something like:

`\emph{text here}` --> `text here`

Default value: All keys set to |g:vimtex_syntax_conceal_default|.
Default value: >

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

*g:vimtex_syntax_conceal_disable*
The option |g:vimtex_syntax_conceal| allows to selectively disable conceal
features. For convenience, this option allows to disable all conceal
features in one go. For more info, see |vimtex-syntax-conceal|.

Default value: 0

*g:vimtex_syntax_conceal_cites*
A simple dictionary to control how citation conceal should work. It has
Expand Down Expand Up @@ -2351,8 +2372,7 @@ OPTIONS *vimtex-options*
array~
asymptote~
babel~
`conceal` whether to enable conceal
Default: |g:vimtex_syntax_conceal_default|
`conceal` whether to enable conceal; enabled by default
beamer~
biblatex~
booktabs~
Expand Down Expand Up @@ -4076,7 +4096,8 @@ are several major differences that users may want to be aware of:
Associated settings:
* |g:vimtex_syntax_enabled|
* |g:vimtex_syntax_conceal|
* |g:vimtex_syntax_conceal_default|
* |g:vimtex_syntax_conceal_cites|
* |g:vimtex_syntax_conceal_disable|
* |g:vimtex_syntax_nested|
* |g:vimtex_syntax_nospell_commands|
* |g:vimtex_syntax_packages|
Expand All @@ -4088,9 +4109,9 @@ VimTeX utilizes the |syn-conceal| feature of Vim to allow displaying commands
like `\alpha` as `α`. That is, various elements/commands can be concealed or
substituted with a unicode symbol.

This feature is enabled by default. It can be fully disabled with
|g:vimtex_syntax_conceal_default| or specific types of concealments can be
disabled with |g:vimtex_syntax_conceal|.
This feature is mostly enabled by default. Various types of concealments can
be enabled/disabled with |g:vimtex_syntax_conceal|. The entire feature can be
fully disabled with |g:vimtex_syntax_conceal_disable|.

For conceals to work properly, one must set the option 'conceallevel' to 2. It
is also good to be aware of the 'concealcursor' option.
Expand Down Expand Up @@ -5781,6 +5802,10 @@ The following changelog only logs particularly important changes, such as
changes that break backwards compatibility. See the git log for the detailed
changelog.

2021-10-09: Better options for syntax conceal~
Deprecated *g:vimtex_syntax_conceal_default* in favour of
|g:vimtex_syntax_conceal_disable|.

2020-11-16: More flexible package syntax options~
Deprecate *g:vimtex_syntax_autoload_packages* in favor of
|g:vimtex_syntax_packages|, which allows more fine grained control over each
Expand Down
8 changes: 8 additions & 0 deletions test/test-syntax/test-conceal.tex
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,12 @@

$$\lVert \mathrm{w} \rVert_2^2$$

\chapter{test}

\section{test}

\subsection{testing}

\subsubsection{testing}

\end{document}