Fixed #648: Improve natbib syntax support

This commit is contained in:
Karl Yngve Lervåg 2016-12-28 12:58:01 +01:00
parent 6b5c633fc8
commit 0382995382
2 changed files with 46 additions and 39 deletions

View File

@ -64,13 +64,12 @@ highlight link texHyperref texRefZone
" }}}1
" {{{1 Improve support for cite commands
if get(g:, 'tex_fast', 'r') =~# 'r'
"
" biblatex
"
execute 'syntax match texStatement /\v\\%(' . join([
\ '[Cc]iteauthor\*?',
\ '[Cc]ite%(title|year|date)?\*?',
\ 'citeurl',
for s:pattern in [
\ 'cite[pt]\*?',
\ 'citeal[tp]\*?',
\ 'cite(num|text|url)',
\ '[Cc]ite%(title|author|year(par)?|date)\*?',
\ '[Pp]arencite\*?',
\ 'foot%(full)?cite%(text)?',
\ 'fullcite',
@ -78,34 +77,29 @@ if get(g:, 'tex_fast', 'r') =~# 'r'
\ '[Ss]martcite',
\ 'supercite',
\ '[Aa]utocite\*?',
\ '[Ppf]?[Nn]otecite'], '|') . ')/'
\ '[Ppf]?[Nn]otecite',
\]
execute 'syntax match texStatement'
\ '/\v\\' . s:pattern . '\ze\s*\{/'
\ 'nextgroup=texRefOption,texCite'
endfor
execute 'syntax match texStatement /\v\\%(' . join([
for s:pattern in [
\ '[Cc]ites',
\ '[Pp]arencites',
\ 'footcite%(s|texts)',
\ '[Tt]extcites',
\ '[Ss]martcites',
\ 'supercites',
\ '[Aa]utocites'], '|') . ')/'
\ '[Aa]utocites',
\ '[pPfFsStTaA]?[Vv]olcites?',
\ 'cite%(field|list|name)',
\]
execute 'syntax match texStatement'
\ '/\v\\' . s:pattern . '\ze\s*\{/'
\ 'nextgroup=texRefOptions,texCites'
endfor
execute 'syntax match texStatement /\\[pPfFsStTaA]\?[Vv]olcites\?/'
\ 'nextgroup=texRefOptions,texCites'
execute 'syntax match texStatement /\\cite\%(field\|list\|name\)/'
\ 'nextgroup=texRefOptions,texCites'
"
" natbib
"
syntax match texStatement '\\cite\%([tp]\*\?\)\?'
\ nextgroup=texRefOption,texCite
"
" Common
"
syntax region texRefOptions contained matchgroup=Delimiter
\ start='\[' end=']'
\ contains=@texRefGroup,texRefZone

View File

@ -87,6 +87,19 @@ const double pi = 3.1415926535
\urldef{\mysite}\url{http://example.com}
\hyperref[asdasd]{asd}
% Cite commands
\citet*{}
\citealt{}
\citealt*{}
\citealp{}
\citealp*{}
\citenum{}
\citetext{}
\citeauthor{}
\citeauthor*{}
\citeyear{}
\citeyearpar{}
\end{document}
% vim: fdl=9