gitattributes.vim 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. " Vim syntax file
  2. " Language: git attributes
  3. " Maintainer: ObserverOfTime <chronobserver@disroot.org>
  4. " Filenames: .gitattributes, *.git/info/attributes
  5. " Last Change: 2022 Sep 09
  6. if exists('b:current_syntax')
  7. finish
  8. endif
  9. let s:cpo_save = &cpoptions
  10. set cpoptions&vim
  11. " Comment
  12. syn keyword gitattributesTodo contained TODO FIXME XXX
  13. syn match gitattributesComment /^\s*#.*/ contains=gitattributesTodo
  14. " Pattern
  15. syn match gitattributesPattern /^\s*#\@!\(".\+"\|\S\+\)/ skipwhite
  16. \ nextgroup=gitattributesAttrPrefixed,gitattributesAttrAssigned skipwhite
  17. \ contains=gitattributesGlob,gitattributesRange,gitattributesSeparator
  18. syn match gitattributesGlob /\\\@1<![?*]/ contained
  19. syn match gitattributesRange /\\\@1<!\[.\{-}\]/ contained
  20. syn match gitattributesSeparator '/' contained
  21. " Attribute
  22. syn match gitattributesAttrPrefixed /[!-]\?[A-Za-z0-9_.][-A-Za-z0-9_.]*/
  23. \ transparent contained skipwhite
  24. \ nextgroup=gitattributesAttrPrefixed,gitattributesAttrAssigned
  25. \ contains=gitattributesPrefix,gitattributesName
  26. syn match gitattributesAttrAssigned /[A-Za-z0-9_.][-A-Za-z0-9_.]*=\S\+/
  27. \ transparent contained skipwhite
  28. \ nextgroup=gitattributesAttrPrefixed,gitattributesAttrAssigned
  29. \ contains=gitattributesName,gitattributesAssign,gitattributesBoolean,gitattributesString
  30. syn match gitattributesName /[A-Za-z0-9_.][-A-Za-z0-9_.]*/
  31. \ contained nextgroup=gitattributesAssign
  32. syn match gitattributesPrefix /[!-]/ contained
  33. \ nextgroup=gitAttributesName
  34. syn match gitattributesAssign '=' contained
  35. \ nextgroup=gitattributesBoolean,gitattributesString
  36. syn match gitattributesString /=\@1<=\S\+/ contained
  37. syn keyword gitattributesBoolean true false contained
  38. " Macro
  39. syn match gitattributesMacro /^\s*\[attr\]\s*\S\+/
  40. \ nextgroup=gitattributesAttribute skipwhite
  41. hi def link gitattributesAssign Operator
  42. hi def link gitattributesBoolean Boolean
  43. hi def link gitattributesComment Comment
  44. hi def link gitattributesGlob Special
  45. hi def link gitattributesMacro Define
  46. hi def link gitattributesName Identifier
  47. hi def link gitattributesPrefix SpecialChar
  48. hi def link gitattributesRange Special
  49. hi def link gitattributesSeparator Delimiter
  50. hi def link gitattributesString String
  51. hi def link gitattributesTodo Todo
  52. let b:current_syntax = 'gitattributes'
  53. let &cpoptions = s:cpo_save
  54. unlet s:cpo_save