1071d4279SBram Moolenaar" Vim syntax file 2071d4279SBram Moolenaar" Language: BibTeX (bibliographic database format for (La)TeX) 3071d4279SBram Moolenaar" Maintainer: Bernd Feige <[email protected]> 4071d4279SBram Moolenaar" Filenames: *.bib 5*01164a65SBram Moolenaar" Last Change: 2017 Sep 29 6071d4279SBram Moolenaar 7071d4279SBram Moolenaar" Thanks to those who pointed out problems with this file or supplied fixes! 8071d4279SBram Moolenaar 9071d4279SBram Moolenaar" Initialization 10071d4279SBram Moolenaar" ============== 1189bcfda6SBram Moolenaar" quit when a syntax file was already loaded 1289bcfda6SBram Moolenaarif exists("b:current_syntax") 13071d4279SBram Moolenaar finish 14071d4279SBram Moolenaarendif 15071d4279SBram Moolenaar 16b6b046b2SBram Moolenaarlet s:cpo_save = &cpo 17b6b046b2SBram Moolenaarset cpo&vim 18b6b046b2SBram Moolenaar 19071d4279SBram Moolenaar" Ignore case 20071d4279SBram Moolenaarsyn case ignore 21071d4279SBram Moolenaar 22071d4279SBram Moolenaar" Keywords 23071d4279SBram Moolenaar" ======== 24071d4279SBram Moolenaarsyn keyword bibType contained article book booklet conference inbook 25071d4279SBram Moolenaarsyn keyword bibType contained incollection inproceedings manual 26071d4279SBram Moolenaarsyn keyword bibType contained mastersthesis misc phdthesis 27071d4279SBram Moolenaarsyn keyword bibType contained proceedings techreport unpublished 2876f3b1adSBram Moolenaarsyn keyword bibType contained string preamble 29071d4279SBram Moolenaar 30071d4279SBram Moolenaarsyn keyword bibEntryKw contained address annote author booktitle chapter 31071d4279SBram Moolenaarsyn keyword bibEntryKw contained crossref edition editor howpublished 32071d4279SBram Moolenaarsyn keyword bibEntryKw contained institution journal key month note 33071d4279SBram Moolenaarsyn keyword bibEntryKw contained number organization pages publisher 34071d4279SBram Moolenaarsyn keyword bibEntryKw contained school series title type volume year 3582af8710SBram Moolenaar 3682af8710SBram Moolenaar" biblatex keywords, cf. http://mirrors.ctan.org/macros/latex/contrib/biblatex/doc/biblatex.pdf 3782af8710SBram Moolenaarsyn keyword bibType contained mvbook bookinbook suppbook collection mvcollection suppcollection 3882af8710SBram Moolenaarsyn keyword bibType contained online patent periodical suppperiodical mvproceedings reference 3982af8710SBram Moolenaarsyn keyword bibType contained mvreference inreference report set thesis xdata customa customb 4082af8710SBram Moolenaarsyn keyword bibType contained customc customd custome customf electronic www artwork audio bibnote 4182af8710SBram Moolenaarsyn keyword bibType contained commentary image jurisdiction legislation legal letter movie music 4282af8710SBram Moolenaarsyn keyword bibType contained performance review software standard video 4382af8710SBram Moolenaar 4482af8710SBram Moolenaarsyn keyword bibEntryKw contained abstract isbn issn keywords url 4582af8710SBram Moolenaarsyn keyword bibEntryKw contained addendum afterwordannotation annotation annotator authortype 4682af8710SBram Moolenaarsyn keyword bibEntryKw contained bookauthor bookpagination booksubtitle booktitleaddon 4782af8710SBram Moolenaarsyn keyword bibEntryKw contained commentator date doi editora editorb editorc editortype 4882af8710SBram Moolenaarsyn keyword bibEntryKw contained editoratype editorbtype editorctype eid entrysubtype 4982af8710SBram Moolenaarsyn keyword bibEntryKw contained eprint eprintclass eprinttype eventdate eventtitle 5082af8710SBram Moolenaarsyn keyword bibEntryKw contained eventtitleaddon file foreword holder indextitle 5182af8710SBram Moolenaarsyn keyword bibEntryKw contained introduction isan ismn isrn issue issuesubtitle 5282af8710SBram Moolenaarsyn keyword bibEntryKw contained issuetitle iswc journalsubtitle journaltitle label 5382af8710SBram Moolenaarsyn keyword bibEntryKw contained language library location mainsubtitle maintitle 5482af8710SBram Moolenaarsyn keyword bibEntryKw contained maintitleaddon nameaddon origdate origlanguage 5582af8710SBram Moolenaarsyn keyword bibEntryKw contained origlocation origpublisher origtitle pagetotal 5682af8710SBram Moolenaarsyn keyword bibEntryKw contained pagination part pubstate reprinttitle shortauthor 5782af8710SBram Moolenaarsyn keyword bibEntryKw contained shorteditor shorthand shorthandintro shortjournal 5882af8710SBram Moolenaarsyn keyword bibEntryKw contained shortseries shorttitle subtitle titleaddon translator 5982af8710SBram Moolenaarsyn keyword bibEntryKw contained urldate venue version volumes entryset execute gender 6082af8710SBram Moolenaarsyn keyword bibEntryKw contained langid langidopts ids indexsorttitle options presort 6182af8710SBram Moolenaarsyn keyword bibEntryKw contained related relatedoptions relatedtype relatedstring 6282af8710SBram Moolenaarsyn keyword bibEntryKw contained sortkey sortname sortshorthand sorttitle sortyear xdata 6382af8710SBram Moolenaarsyn keyword bibEntryKw contained xref namea nameb namec nameatype namebtype namectype 6482af8710SBram Moolenaarsyn keyword bibEntryKw contained lista listb listc listd liste listf usera userb userc 6582af8710SBram Moolenaarsyn keyword bibEntryKw contained userd usere userf verba verbb verbc archiveprefix pdf 6682af8710SBram Moolenaarsyn keyword bibEntryKw contained primaryclass 6782af8710SBram Moolenaar 68071d4279SBram Moolenaar" Non-standard: 69251e1912SBram Moolenaar" AMS mref http://www.ams.org/mref 70251e1912SBram Moolenaarsyn keyword bibNSEntryKw contained mrclass mrnumber mrreviewer fjournal coden 71071d4279SBram Moolenaar 72071d4279SBram Moolenaar" Clusters 73071d4279SBram Moolenaar" ======== 74220adb1eSBram Moolenaarsyn cluster bibVarContents contains=bibUnescapedSpecial,bibBrace,bibParen,bibMath 75071d4279SBram Moolenaar" This cluster is empty but things can be added externally: 76071d4279SBram Moolenaar"syn cluster bibCommentContents 77071d4279SBram Moolenaar 78071d4279SBram Moolenaar" Matches 79071d4279SBram Moolenaar" ======= 80071d4279SBram Moolenaarsyn match bibUnescapedSpecial contained /[^\\][%&]/hs=s+1 81071d4279SBram Moolenaarsyn match bibKey contained /\s*[^ \t}="]\+,/hs=s,he=e-1 nextgroup=bibField 82071d4279SBram Moolenaarsyn match bibVariable contained /[^{}," \t=]/ 838aff23a1SBram Moolenaarsyn region bibComment start=/./ end=/^\s*@/me=e-1 contains=@bibCommentContents nextgroup=bibEntry 84*01164a65SBram Moolenaarsyn region bibMath contained start=/\(\\\)\@<!\$/ end=/\$/ skip=/\(\\\$\)/ 85071d4279SBram Moolenaarsyn region bibQuote contained start=/"/ end=/"/ skip=/\(\\"\)/ contains=@bibVarContents 86071d4279SBram Moolenaarsyn region bibBrace contained start=/{/ end=/}/ skip=/\(\\[{}]\)/ contains=@bibVarContents 87071d4279SBram Moolenaarsyn region bibParen contained start=/(/ end=/)/ skip=/\(\\[()]\)/ contains=@bibVarContents 88071d4279SBram Moolenaarsyn region bibField contained start="\S\+\s*=\s*" end=/[}),]/me=e-1 contains=bibEntryKw,bibNSEntryKw,bibBrace,bibParen,bibQuote,bibVariable 89*01164a65SBram Moolenaarsyn region bibEntryData contained start=/[{(]/ms=e+1 end=/[})]/me=e-1 contains=bibKey,bibField,bibComment3 90071d4279SBram Moolenaar" Actually, 5.8 <= Vim < 6.0 would ignore the `fold' keyword anyway, but Vim<5.8 would produce 91071d4279SBram Moolenaar" an error, so we explicitly distinguish versions with and without folding functionality: 92251e1912SBram Moolenaarsyn region bibEntry start=/@\S\+\s*[{(]/ end=/^\s*[})]/ transparent fold contains=bibType,bibEntryData nextgroup=bibComment 93251e1912SBram Moolenaarsyn region bibComment2 start=/@Comment\s*[{(]/ end=/^\s*[})]/me=e-1 contains=@bibCommentContents nextgroup=bibEntry 94*01164a65SBram Moolenaar" biblatex style comments inside a bibEntry 95*01164a65SBram Moolenaarsyn match bibComment3 "%.*" 96071d4279SBram Moolenaar 97071d4279SBram Moolenaar" Synchronization 98071d4279SBram Moolenaar" =============== 99071d4279SBram Moolenaarsyn sync match All grouphere bibEntry /^\s*@/ 100071d4279SBram Moolenaarsyn sync maxlines=200 101071d4279SBram Moolenaarsyn sync minlines=50 102071d4279SBram Moolenaar 103071d4279SBram Moolenaar" Highlighting defaults 104071d4279SBram Moolenaar" ===================== 105071d4279SBram Moolenaar" Define the default highlighting. 10689bcfda6SBram Moolenaar" Only when an item doesn't have highlighting yet 10789bcfda6SBram Moolenaar 108f37506f6SBram Moolenaarhi def link bibType Identifier 109f37506f6SBram Moolenaarhi def link bibEntryKw Statement 110f37506f6SBram Moolenaarhi def link bibNSEntryKw PreProc 111f37506f6SBram Moolenaarhi def link bibKey Special 112f37506f6SBram Moolenaarhi def link bibVariable Constant 113f37506f6SBram Moolenaarhi def link bibUnescapedSpecial Error 114f37506f6SBram Moolenaarhi def link bibComment Comment 115f37506f6SBram Moolenaarhi def link bibComment2 Comment 116*01164a65SBram Moolenaarhi def link bibComment3 Comment 117071d4279SBram Moolenaar 118071d4279SBram Moolenaarlet b:current_syntax = "bib" 119b6b046b2SBram Moolenaar 120b6b046b2SBram Moolenaarlet &cpo = s:cpo_save 121b6b046b2SBram Moolenaarunlet s:cpo_save 122