2 " Language: generic git output
3 " Maintainer: Tim Pope <vimNOSPAM@tpope.info>
4 " Last Change: 2008 Mar 21
6 if exists("b:current_syntax")
13 syn include @gitDiff syntax/diff.vim
15 syn region gitHead start=/\%^/ end=/^$/
16 syn region gitHead start=/\%(^commit \x\{40\}$\)\@=/ end=/^$/
18 " For git reflog and git show ...^{tree}, avoid sync issues
19 syn match gitHead /^\d\{6\} \%(\w\{4} \)\=\x\{40\}\%( [0-3]\)\=\t.*/
20 syn match gitHead /^\x\{40\} \x\{40}\t.*/
22 syn region gitDiff start=/^\%(diff --git \)\@=/ end=/^\%(diff --git \|$\)\@=/ contains=@gitDiff fold
23 syn region gitDiff start=/^\%(@@ -\)\@=/ end=/^\%(diff --git \|$\)\@=/ contains=@gitDiff
25 syn match gitKeyword /^\%(object\|type\|tag\|commit\|tree\|parent\|encoding\)\>/ contained containedin=gitHead nextgroup=gitHash,gitType skipwhite
26 syn match gitKeyword /^\%(tag\>\|ref:\)/ contained containedin=gitHead nextgroup=gitReference skipwhite
27 syn match gitKeyword /^Merge:/ contained containedin=gitHead nextgroup=gitHashAbbrev skipwhite
28 syn match gitMode /^\d\{6\}/ contained containedin=gitHead nextgroup=gitType,gitHash skipwhite
29 syn match gitIdentityKeyword /^\%(author\|committer\|tagger\)\>/ contained containedin=gitHead nextgroup=gitIdentity skipwhite
30 syn match gitIdentityHeader /^\%(Author\|Commit\|Tagger\):/ contained containedin=gitHead nextgroup=gitIdentity skipwhite
31 syn match gitDateHeader /^\%(AuthorDate\|CommitDate\|Date\):/ contained containedin=gitHead nextgroup=gitDate skipwhite
32 syn match gitIdentity /\S.\{-\} <[^>]*>/ contained nextgroup=gitDate skipwhite
33 syn region gitEmail matchgroup=gitEmailDelimiter start=/</ end=/>/ keepend oneline contained containedin=gitIdentity
35 syn match gitReflogHeader /^Reflog:/ contained containedin=gitHead nextgroup=gitReflogMiddle skipwhite
36 syn match gitReflogHeader /^Reflog message:/ contained containedin=gitHead skipwhite
37 syn match gitReflogMiddle /\S\+@{\d\+} (/he=e-2 nextgroup=gitIdentity
39 syn match gitDate /\<\u\l\l \u\l\l \d\=\d \d\d:\d\d:\d\d \d\d\d\d [+-]\d\d\d\d/ contained
40 syn match gitDate /-\=\d\+ [+-]\d\d\d\d\>/ contained
41 syn match gitDate /\<\d\+ \l\+ ago\>/ contained
42 syn match gitType /\<\%(tag\|commit\|tree\|blob\)\>/ contained nextgroup=gitHash skipwhite
43 syn match gitStage /\<\d\t\@=/ contained
44 syn match gitReference /\S\+\S\@!/ contained
45 syn match gitHash /\<\x\{40\}\>/ contained nextgroup=gitIdentity,gitStage skipwhite
46 syn match gitHash /^\<\x\{40\}\>/ containedin=gitHead contained nextgroup=gitHash skipwhite
47 syn match gitHashAbbrev /\<\x\{4,39\}\.\.\./he=e-3 contained nextgroup=gitHashAbbrev skipwhite
48 syn match gitHashAbbrev /\<\x\{40\}\>/ contained nextgroup=gitHashAbbrev skipwhite
50 hi def link gitDateHeader gitIdentityHeader
51 hi def link gitIdentityHeader gitIdentityKeyword
52 hi def link gitIdentityKeyword Label
53 hi def link gitReflogHeader gitKeyword
54 hi def link gitKeyword Keyword
55 hi def link gitIdentity String
56 hi def link gitEmailDelimiter Delimiter
57 hi def link gitEmail Special
58 hi def link gitDate Number
59 hi def link gitMode Number
60 hi def link gitHashAbbrev gitHash
61 hi def link gitHash Identifier
62 hi def link gitReflogMiddle gitReference
63 hi def link gitReference Function
64 hi def link gitStage gitType
65 hi def link gitType Type
67 let b:current_syntax = "git"