Skip to content

Commit

Permalink
feat(syntax): concealed cites for footcite
Browse files Browse the repository at this point in the history
refer: #1965
  • Loading branch information
lervag committed Apr 9, 2021
1 parent 8178ade commit bdd8f98
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
13 changes: 8 additions & 5 deletions autoload/vimtex/syntax/p/biblatex.vim
Original file line number Diff line number Diff line change
Expand Up @@ -38,25 +38,28 @@ function! vimtex#syntax#p#biblatex#load(cfg) abort " {{{1
highlight def link texRefOpts texRefOpt

if g:vimtex_syntax_conceal.cites
let s:re_concealed_cites = '\v\\%(' . join([
\ '(foot)?cite[tp]?',
\ '%([Tt]ext|[Ss]mart|[Aa]uto)cite',
\ ], '|') . ')>\*?'
call s:match_conceal_cites_{g:vimtex_syntax_conceal_cites.type}()
endif
endfunction

" }}}1

function! s:match_conceal_cites_brackets() abort " {{{1
syntax match texCmdRefConcealed
\ "\v\\%(cite[tp]?>\*?|%([Tt]ext|[Ss]mart|[Aa]uto)cite>)"
\ conceal skipwhite nextgroup=texRefConcealedOpt1,texRefConcealedArg
execute 'syntax match texCmdRefConcealed'
\ '"' . s:re_concealed_cites . '"'
\ 'conceal skipwhite nextgroup=texRefConcealedOpt1,texRefConcealedArg'
endfunction

" }}}1
function! s:match_conceal_cites_icon() abort " {{{1
if empty(g:vimtex_syntax_conceal_cites.icon) | return | endif

execute 'syntax match texCmdRefConcealed'
\ '"\v\\%(cite[tp]?\*?|%([Tt]ext|[Ss]mart|[Aa]uto)cite)'
\ . '%(\[[^]]*\]){,2}\{[^}]*\}"'
\ '"' . s:re_concealed_cites . '%(\[[^]]*\]){,2}\{[^}]*\}"'
\ 'conceal cchar=' . g:vimtex_syntax_conceal_cites.icon
endfunction

Expand Down
1 change: 1 addition & 0 deletions test/test-syntax/test-biblatex.tex
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
\citeyear{}
\citeyearpar{}
\bibentry{}
\footcite{}

% Conceal example
Bla bla bla, see Ref.~\cite{John2012Measurement,Anne2017Bifurcation}. For more info, see also \cite{Bob2025Mystery}.
Expand Down

0 comments on commit bdd8f98

Please sign in to comment.