2 " Language: BibTeX (bibliographic database format for (La)TeX)
3 " Maintainer: Bernd Feige <Bernd.Feige@gmx.net>
5 " Last Change: 2011 Dec 25
7 " Thanks to those who pointed out problems with this file or supplied fixes!
11 " For version 5.x: Clear all syntax items
12 " For version 6.x: Quit when a syntax file was already loaded
15 elseif exists("b:current_syntax")
27 syn keyword bibType contained article book booklet conference inbook
28 syn keyword bibType contained incollection inproceedings manual
29 syn keyword bibType contained mastersthesis misc phdthesis
30 syn keyword bibType contained proceedings techreport unpublished
31 syn keyword bibType contained string
33 syn keyword bibEntryKw contained address annote author booktitle chapter
34 syn keyword bibEntryKw contained crossref edition editor howpublished
35 syn keyword bibEntryKw contained institution journal key month note
36 syn keyword bibEntryKw contained number organization pages publisher
37 syn keyword bibEntryKw contained school series title type volume year
39 syn keyword bibNSEntryKw contained abstract isbn issn keywords url
40 " AMS mref http://www.ams.org/mref
41 syn keyword bibNSEntryKw contained mrclass mrnumber mrreviewer fjournal coden
45 syn cluster bibVarContents contains=bibUnescapedSpecial,bibBrace,bibParen
46 " This cluster is empty but things can be added externally:
47 "syn cluster bibCommentContents
51 syn match bibUnescapedSpecial contained /[^\\][%&]/hs=s+1
52 syn match bibKey contained /\s*[^ \t}="]\+,/hs=s,he=e-1 nextgroup=bibField
53 syn match bibVariable contained /[^{}," \t=]/
54 syn region bibComment start=/./ end=/^\s*@/me=e-1 contains=@bibCommentContents nextgroup=bibEntry
55 syn region bibQuote contained start=/"/ end=/"/ skip=/\(\\"\)/ contains=@bibVarContents
56 syn region bibBrace contained start=/{/ end=/}/ skip=/\(\\[{}]\)/ contains=@bibVarContents
57 syn region bibParen contained start=/(/ end=/)/ skip=/\(\\[()]\)/ contains=@bibVarContents
58 syn region bibField contained start="\S\+\s*=\s*" end=/[}),]/me=e-1 contains=bibEntryKw,bibNSEntryKw,bibBrace,bibParen,bibQuote,bibVariable
59 syn region bibEntryData contained start=/[{(]/ms=e+1 end=/[})]/me=e-1 contains=bibKey,bibField
60 " Actually, 5.8 <= Vim < 6.0 would ignore the `fold' keyword anyway, but Vim<5.8 would produce
61 " an error, so we explicitly distinguish versions with and without folding functionality:
63 syn region bibEntry start=/@\S\+\s*[{(]/ end=/^\s*[})]/ transparent contains=bibType,bibEntryData nextgroup=bibComment
65 syn region bibEntry start=/@\S\+\s*[{(]/ end=/^\s*[})]/ transparent fold contains=bibType,bibEntryData nextgroup=bibComment
67 syn region bibComment2 start=/@Comment\s*[{(]/ end=/^\s*[})]/me=e-1 contains=@bibCommentContents nextgroup=bibEntry
71 syn sync match All grouphere bibEntry /^\s*@/
75 " Highlighting defaults
76 " =====================
77 " Define the default highlighting.
78 " For version 5.7 and earlier: only when not done already
79 " For version 5.8 and later: only when an item doesn't have highlighting yet
80 if version >= 508 || !exists("did_bib_syn_inits")
82 let did_bib_syn_inits = 1
83 command -nargs=+ HiLink hi link <args>
85 command -nargs=+ HiLink hi def link <args>
87 HiLink bibType Identifier
88 HiLink bibEntryKw Statement
89 HiLink bibNSEntryKw PreProc
91 HiLink bibVariable Constant
92 HiLink bibUnescapedSpecial Error
93 HiLink bibComment Comment
94 HiLink bibComment2 Comment
98 let b:current_syntax = "bib"
100 let &cpo = s:cpo_save