bib.vim 5.9 KB

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