blob: 8bd0528e1e1c38d01b46a83dcccda408df3ed5f7 [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001" Vim syntax file
2" Language: BibTeX (bibliographic database format for (La)TeX)
3" Maintainer: Bernd Feige <Bernd.Feige@gmx.net>
4" Filenames: *.bib
Bram Moolenaar82af8712016-06-04 20:20:29 +02005" Last Change: 2016 May 31
Bram Moolenaar071d4272004-06-13 20:20:40 +00006
7" Thanks to those who pointed out problems with this file or supplied fixes!
8
9" Initialization
10" ==============
11" For version 5.x: Clear all syntax items
12" For version 6.x: Quit when a syntax file was already loaded
13if version < 600
14 syntax clear
15elseif exists("b:current_syntax")
16 finish
17endif
18
Bram Moolenaarb6b046b2011-12-30 13:11:27 +010019let s:cpo_save = &cpo
20set cpo&vim
21
Bram Moolenaar071d4272004-06-13 20:20:40 +000022" Ignore case
23syn case ignore
24
25" Keywords
26" ========
27syn keyword bibType contained article book booklet conference inbook
28syn keyword bibType contained incollection inproceedings manual
29syn keyword bibType contained mastersthesis misc phdthesis
30syn keyword bibType contained proceedings techreport unpublished
Bram Moolenaar76f3b1a2014-03-27 22:30:07 +010031syn keyword bibType contained string preamble
Bram Moolenaar071d4272004-06-13 20:20:40 +000032
33syn keyword bibEntryKw contained address annote author booktitle chapter
34syn keyword bibEntryKw contained crossref edition editor howpublished
35syn keyword bibEntryKw contained institution journal key month note
36syn keyword bibEntryKw contained number organization pages publisher
37syn keyword bibEntryKw contained school series title type volume year
Bram Moolenaar82af8712016-06-04 20:20:29 +020038
39" biblatex keywords, cf. http://mirrors.ctan.org/macros/latex/contrib/biblatex/doc/biblatex.pdf
40syn keyword bibType contained mvbook bookinbook suppbook collection mvcollection suppcollection
41syn keyword bibType contained online patent periodical suppperiodical mvproceedings reference
42syn keyword bibType contained mvreference inreference report set thesis xdata customa customb
43syn keyword bibType contained customc customd custome customf electronic www artwork audio bibnote
44syn keyword bibType contained commentary image jurisdiction legislation legal letter movie music
45syn keyword bibType contained performance review software standard video
46
47syn keyword bibEntryKw contained abstract isbn issn keywords url
48syn keyword bibEntryKw contained addendum afterwordannotation annotation annotator authortype
49syn keyword bibEntryKw contained bookauthor bookpagination booksubtitle booktitleaddon
50syn keyword bibEntryKw contained commentator date doi editora editorb editorc editortype
51syn keyword bibEntryKw contained editoratype editorbtype editorctype eid entrysubtype
52syn keyword bibEntryKw contained eprint eprintclass eprinttype eventdate eventtitle
53syn keyword bibEntryKw contained eventtitleaddon file foreword holder indextitle
54syn keyword bibEntryKw contained introduction isan ismn isrn issue issuesubtitle
55syn keyword bibEntryKw contained issuetitle iswc journalsubtitle journaltitle label
56syn keyword bibEntryKw contained language library location mainsubtitle maintitle
57syn keyword bibEntryKw contained maintitleaddon nameaddon origdate origlanguage
58syn keyword bibEntryKw contained origlocation origpublisher origtitle pagetotal
59syn keyword bibEntryKw contained pagination part pubstate reprinttitle shortauthor
60syn keyword bibEntryKw contained shorteditor shorthand shorthandintro shortjournal
61syn keyword bibEntryKw contained shortseries shorttitle subtitle titleaddon translator
62syn keyword bibEntryKw contained urldate venue version volumes entryset execute gender
63syn keyword bibEntryKw contained langid langidopts ids indexsorttitle options presort
64syn keyword bibEntryKw contained related relatedoptions relatedtype relatedstring
65syn keyword bibEntryKw contained sortkey sortname sortshorthand sorttitle sortyear xdata
66syn keyword bibEntryKw contained xref namea nameb namec nameatype namebtype namectype
67syn keyword bibEntryKw contained lista listb listc listd liste listf usera userb userc
68syn keyword bibEntryKw contained userd usere userf verba verbb verbc archiveprefix pdf
69syn keyword bibEntryKw contained primaryclass
70
Bram Moolenaar071d4272004-06-13 20:20:40 +000071" Non-standard:
Bram Moolenaar251e1912011-06-19 05:09:16 +020072" AMS mref http://www.ams.org/mref
73syn keyword bibNSEntryKw contained mrclass mrnumber mrreviewer fjournal coden
Bram Moolenaar071d4272004-06-13 20:20:40 +000074
75" Clusters
76" ========
77syn cluster bibVarContents contains=bibUnescapedSpecial,bibBrace,bibParen
78" This cluster is empty but things can be added externally:
79"syn cluster bibCommentContents
80
81" Matches
82" =======
83syn match bibUnescapedSpecial contained /[^\\][%&]/hs=s+1
84syn match bibKey contained /\s*[^ \t}="]\+,/hs=s,he=e-1 nextgroup=bibField
85syn match bibVariable contained /[^{}," \t=]/
Bram Moolenaar8aff23a2005-08-19 20:40:30 +000086syn region bibComment start=/./ end=/^\s*@/me=e-1 contains=@bibCommentContents nextgroup=bibEntry
Bram Moolenaar071d4272004-06-13 20:20:40 +000087syn region bibQuote contained start=/"/ end=/"/ skip=/\(\\"\)/ contains=@bibVarContents
88syn region bibBrace contained start=/{/ end=/}/ skip=/\(\\[{}]\)/ contains=@bibVarContents
89syn region bibParen contained start=/(/ end=/)/ skip=/\(\\[()]\)/ contains=@bibVarContents
90syn region bibField contained start="\S\+\s*=\s*" end=/[}),]/me=e-1 contains=bibEntryKw,bibNSEntryKw,bibBrace,bibParen,bibQuote,bibVariable
91syn region bibEntryData contained start=/[{(]/ms=e+1 end=/[})]/me=e-1 contains=bibKey,bibField
92" Actually, 5.8 <= Vim < 6.0 would ignore the `fold' keyword anyway, but Vim<5.8 would produce
93" an error, so we explicitly distinguish versions with and without folding functionality:
94if version < 600
Bram Moolenaar251e1912011-06-19 05:09:16 +020095 syn region bibEntry start=/@\S\+\s*[{(]/ end=/^\s*[})]/ transparent contains=bibType,bibEntryData nextgroup=bibComment
Bram Moolenaar071d4272004-06-13 20:20:40 +000096else
Bram Moolenaar251e1912011-06-19 05:09:16 +020097 syn region bibEntry start=/@\S\+\s*[{(]/ end=/^\s*[})]/ transparent fold contains=bibType,bibEntryData nextgroup=bibComment
Bram Moolenaar071d4272004-06-13 20:20:40 +000098endif
Bram Moolenaar251e1912011-06-19 05:09:16 +020099syn region bibComment2 start=/@Comment\s*[{(]/ end=/^\s*[})]/me=e-1 contains=@bibCommentContents nextgroup=bibEntry
Bram Moolenaar071d4272004-06-13 20:20:40 +0000100
101" Synchronization
102" ===============
103syn sync match All grouphere bibEntry /^\s*@/
104syn sync maxlines=200
105syn sync minlines=50
106
107" Highlighting defaults
108" =====================
109" Define the default highlighting.
110" For version 5.7 and earlier: only when not done already
111" For version 5.8 and later: only when an item doesn't have highlighting yet
112if version >= 508 || !exists("did_bib_syn_inits")
113 if version < 508
114 let did_bib_syn_inits = 1
115 command -nargs=+ HiLink hi link <args>
116 else
117 command -nargs=+ HiLink hi def link <args>
118 endif
119 HiLink bibType Identifier
120 HiLink bibEntryKw Statement
121 HiLink bibNSEntryKw PreProc
122 HiLink bibKey Special
123 HiLink bibVariable Constant
124 HiLink bibUnescapedSpecial Error
125 HiLink bibComment Comment
Bram Moolenaar8aff23a2005-08-19 20:40:30 +0000126 HiLink bibComment2 Comment
Bram Moolenaar071d4272004-06-13 20:20:40 +0000127 delcommand HiLink
128endif
129
130let b:current_syntax = "bib"
Bram Moolenaarb6b046b2011-12-30 13:11:27 +0100131
132let &cpo = s:cpo_save
133unlet s:cpo_save