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