Skip to content

Commit

Permalink
feat(syntax): specify verbose level for bracket cite conceal
Browse files Browse the repository at this point in the history
  • Loading branch information
lervag committed Mar 27, 2021
1 parent 41667e5 commit abe9f36
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 12 deletions.
1 change: 1 addition & 0 deletions autoload/vimtex/options.vim
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ function! vimtex#options#init() abort " {{{1
call s:init_option('vimtex_syntax_conceal_cites', {
\ 'type': 'brackets',
\ 'icon': '📖',
\ 'verbose': v:true,
\})
call s:init_option('vimtex_syntax_nested', {
\ 'aliases' : {
Expand Down
13 changes: 9 additions & 4 deletions autoload/vimtex/syntax/core.vim
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,8 @@ function! vimtex#syntax#core#init_highlights() abort " {{{1
highlight def link texNewenvParm texParm
highlight def link texOptEqual texSymbol
highlight def link texRefOpt texOpt
highlight def link texRefConcealedOpt texRefOpt
highlight def link texRefConcealedOpt1 texRefOpt
highlight def link texRefConcealedOpt2 texRefOpt
highlight def link texRefConcealedArg texRefArg
highlight def link texRefConcealedDelim texDelim
highlight def link texTabularArg texOpt
Expand Down Expand Up @@ -1518,10 +1519,14 @@ endfunction
function! s:match_conceal_cites_brackets() abort " {{{1
syntax match texCmdRefConcealed
\ "\\cite[tp]\?\>\*\?"
\ conceal skipwhite nextgroup=texRefConcealedOpt,texRefConcealedArg
call vimtex#syntax#core#new_opt('texRefConcealedOpt', {
\ conceal skipwhite nextgroup=texRefConcealedOpt1,texRefConcealedArg
call vimtex#syntax#core#new_opt('texRefConcealedOpt1', {
\ 'opts': g:vimtex_syntax_conceal_cites.verbose ? '' : 'conceal',
\ 'next': 'texRefConcealedOpt2,texRefConcealedArg',
\})
call vimtex#syntax#core#new_opt('texRefConcealedOpt2', {
\ 'opts': 'conceal',
\ 'next': 'texRefConcealedOpt,texRefConcealedArg',
\ 'next': 'texRefConcealedArg',
\})
call vimtex#syntax#core#new_arg('texRefConcealedArg', {
\ 'contains': 'texComment,@NoSpell,texRefConcealedDelim',
Expand Down
2 changes: 1 addition & 1 deletion autoload/vimtex/syntax/p/biblatex.vim
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ endfunction
function! s:match_conceal_cites_brackets() abort " {{{1
syntax match texCmdRefConcealed
\ "\v\\%(cite[tp]?>\*?|%([Tt]ext|[Ss]mart|[Aa]uto)cite>)"
\ conceal skipwhite nextgroup=texRefConcealedOpt,texRefConcealedArg
\ conceal skipwhite nextgroup=texRefConcealedOpt1,texRefConcealedArg
endfunction

" }}}1
Expand Down
19 changes: 15 additions & 4 deletions doc/vimtex.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2086,27 +2086,38 @@ OPTIONS *vimtex-options*
Default value: All keys set to |g:vimtex_syntax_conceal_default|.

*g:vimtex_syntax_conceal_cites*
A simple dictionary to control how citation conceal should work. It has two
keys:
A simple dictionary to control how citation conceal should work. It has
three keys:

type~
Specify the type of concealment. There are two options, and the
difference is best explained by example:

Value LaTeX Concealed
----- ----- ---------
'icon' `\cite{Knuth1981}` `📖`
'brackets' `\cite{Knuth1981}` `[Knuth1981]`
`'icon'` `\cite{Knuth1981}` `📖`
`'brackets'` `\cite{Knuth1981}` `[Knuth1981]`

icon~
Specify an icon for `icon` conceal. This must be a single (possibly
multibyte) character.

verbose~
Specify how much to conceal in bracket mode (`type` set to `'bracket'`).
The following table shows how the concealed result depending on the
`'verbose'` value for `\cite[Figure 1]{Knuth1981}`:

Value Concealed
----- ---------
|v:true| `[Figure 1][Knuth1981]`
|v:false| `[Knuth1981]`

Default value: >
let g:vimtex_syntax_conceal_cites = {
\ 'type': 'brackets',
\ 'icon': '📖',
\ 'verbose': v:true,
\}
*g:vimtex_syntax_nested*
Expand Down
6 changes: 3 additions & 3 deletions test/test-syntax/test-biblatex.vim
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ source common.vim

highlight Conceal ctermfg=4 ctermbg=7 guibg=NONE guifg=blue

let g:vimtex_syntax_conceal_cites = {
\ 'type': 'brackets',
\}
" let g:vimtex_syntax_conceal_cites = {
" \ 'type': 'icon',
" \}

silent edit test-biblatex.tex

Expand Down

0 comments on commit abe9f36

Please sign in to comment.