blob: b6d997f45dee0b39543c05526c2429c4c90e0de9 [file] [log] [blame]
Bram Moolenaar71b6d332022-09-10 13:13:14 +01001" 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
7if exists('b:current_syntax')
8 finish
9endif
10
11let s:cpo_save = &cpoptions
12set cpoptions&vim
13
14" Comment
15syn keyword gitattributesTodo contained TODO FIXME XXX
16syn match gitattributesComment /^\s*#.*/ contains=gitattributesTodo
17
18" Pattern
19syn match gitattributesPattern /^\s*#\@!\(".\+"\|\S\+\)/ skipwhite
20 \ nextgroup=gitattributesAttrPrefixed,gitattributesAttrAssigned skipwhite
21 \ contains=gitattributesGlob,gitattributesRange,gitattributesSeparator
22syn match gitattributesGlob /\\\@1<![?*]/ contained
23syn match gitattributesRange /\\\@1<!\[.\{-}\]/ contained
24syn match gitattributesSeparator '/' contained
25
26" Attribute
27syn match gitattributesAttrPrefixed /[!-]\?[A-Za-z0-9_.][-A-Za-z0-9_.]*/
28 \ transparent contained skipwhite
29 \ nextgroup=gitattributesAttrPrefixed,gitattributesAttrAssigned
30 \ contains=gitattributesPrefix,gitattributesName
31syn match gitattributesAttrAssigned /[A-Za-z0-9_.][-A-Za-z0-9_.]*=\S\+/
32 \ transparent contained skipwhite
33 \ nextgroup=gitattributesAttrPrefixed,gitattributesAttrAssigned
34 \ contains=gitattributesName,gitattributesAssign,gitattributesBoolean,gitattributesString
35syn match gitattributesName /[A-Za-z0-9_.][-A-Za-z0-9_.]*/
36 \ contained nextgroup=gitattributesAssign
37syn match gitattributesPrefix /[!-]/ contained
38 \ nextgroup=gitAttributesName
39syn match gitattributesAssign '=' contained
40 \ nextgroup=gitattributesBoolean,gitattributesString
41syn match gitattributesString /=\@1<=\S\+/ contained
42syn keyword gitattributesBoolean true false contained
43
44" Macro
45syn match gitattributesMacro /^\s*\[attr\]\s*\S\+/
46 \ nextgroup=gitattributesAttribute skipwhite
47
48hi def link gitattributesAssign Operator
49hi def link gitattributesBoolean Boolean
50hi def link gitattributesComment Comment
51hi def link gitattributesGlob Special
52hi def link gitattributesMacro Define
53hi def link gitattributesName Identifier
54hi def link gitattributesPrefix SpecialChar
55hi def link gitattributesRange Special
56hi def link gitattributesSeparator Delimiter
57hi def link gitattributesString String
58hi def link gitattributesTodo Todo
59
60let b:current_syntax = 'gitattributes'
61
62let &cpoptions = s:cpo_save
63unlet s:cpo_save