Skip to content

Commit 159b74a

Browse files
committed
fix(syntax): fixed plural cites with conceal
refer: #3212
1 parent 0f2f599 commit 159b74a

File tree

2 files changed

+29
-28
lines changed

2 files changed

+29
-28
lines changed

autoload/vimtex/syntax/p/biblatex.vim

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,33 @@ function! vimtex#syntax#p#biblatex#load(cfg) abort " {{{1
2323
syntax match texCmdRef nextgroup=texRefOpt,texRefArg skipwhite skipnl "\\[Ppf]\?[Nn]otecite\>"
2424
syntax match texCmdRef nextgroup=texRefOpt,texRefArg skipwhite skipnl "\\\%(text\|block\)cquote\>\*\?"
2525

26+
if g:vimtex_syntax_conceal.cites
27+
let l:re_concealed_cites = '\v\\%(' . join([
28+
\ '%([Tt]ext|[Ss]mart|[Aa]uto)cite',
29+
\ '(foot)?cite[tp]?',
30+
\ '[Cc]ite%(title|author|year%(par)?|date)',
31+
\ '[Pp]arencite',
32+
\ '[Ppf]?[Nn]otecite',
33+
\ '[Ss]upercite',
34+
\ 'Cite',
35+
\ 'cite%(num|text|url|field|list|name)',
36+
\ 'citeal[tp]',
37+
\ 'foot%(full)?cite%(text)?',
38+
\ 'footcite',
39+
\ 'fullcite',
40+
\ ], '|') . ')>\*?'
41+
42+
if g:vimtex_syntax_conceal_cites.type ==# 'brackets'
43+
execute 'syntax match texCmdRefConcealed'
44+
\ '"' . l:re_concealed_cites . '"'
45+
\ 'conceal skipwhite nextgroup=texRefConcealedOpt1,texRefConcealedArg'
46+
elseif !empty(g:vimtex_syntax_conceal_cites.icon)
47+
execute 'syntax match texCmdRefConcealed'
48+
\ '"' . l:re_concealed_cites . '%(\[[^]]*\]){,2}\{[^}]*\}"'
49+
\ 'conceal cchar=' . g:vimtex_syntax_conceal_cites.icon
50+
endif
51+
endif
52+
2653
syntax match texCmdRef nextgroup=texRefOpts,texRefArgs skipwhite skipnl "\\[Cc]ites\>"
2754
syntax match texCmdRef nextgroup=texRefOpts,texRefArgs skipwhite skipnl "\\[Pp]arencites\>"
2855
syntax match texCmdRef nextgroup=texRefOpts,texRefArgs skipwhite skipnl "\\footcite\%(s\|texts\)\>"
@@ -37,34 +64,6 @@ function! vimtex#syntax#p#biblatex#load(cfg) abort " {{{1
3764

3865
highlight def link texRefArgs texRefArg
3966
highlight def link texRefOpts texRefOpt
40-
41-
if !g:vimtex_syntax_conceal.cites | return | endif
42-
43-
let l:re_concealed_cites = '\v\\%(' . join([
44-
\ '%([Tt]ext|[Ss]mart|[Aa]uto)cite[s]?',
45-
\ '(foot)?cite[tp]?',
46-
\ '[Aa]utocite[s]?',
47-
\ '[Cc]ite%(title|author|year%(par)?|date)[s]?',
48-
\ '[Pp]arencite[s]?',
49-
\ '[Ppf]?[Nn]otecite',
50-
\ '[Ss]upercite[s]?',
51-
\ 'Cite',
52-
\ 'cite%(num|text|url|field|list|name)',
53-
\ 'citeal[tp]',
54-
\ 'foot%(full)?cite%(text)?',
55-
\ 'footcite%(s|texts)',
56-
\ 'fullcite[s]?',
57-
\ ], '|') . ')>\*?'
58-
59-
if g:vimtex_syntax_conceal_cites.type ==# 'brackets'
60-
execute 'syntax match texCmdRefConcealed'
61-
\ '"' . l:re_concealed_cites . '"'
62-
\ 'conceal skipwhite nextgroup=texRefConcealedOpt1,texRefConcealedArg'
63-
elseif !empty(g:vimtex_syntax_conceal_cites.icon)
64-
execute 'syntax match texCmdRefConcealed'
65-
\ '"' . l:re_concealed_cites . '%(\[[^]]*\]){,2}\{[^}]*\}"'
66-
\ 'conceal cchar=' . g:vimtex_syntax_conceal_cites.icon
67-
endif
6867
endfunction
6968

7069
" }}}1

test/test-syntax/test-biblatex.tex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,6 @@
3737
\volcite{1}[23]{worman}
3838
\volcite[23]{worman}
3939

40+
\autocites[7-9]{Hemingway1940}[3-4]{JiM2020}
41+
4042
\end{document}

0 commit comments

Comments
 (0)