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