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