1" Vim syntax file
2" Language:	git commit file
3" Maintainer:	Tim Pope <vimNOSPAM@tpope.org>
4" Filenames:	*.git/COMMIT_EDITMSG
5" Last Change:	2010 May 21
6
7if exists("b:current_syntax")
8  finish
9endif
10
11syn case match
12syn sync minlines=50
13
14if has("spell")
15  syn spell toplevel
16endif
17
18syn include @gitcommitDiff syntax/diff.vim
19syn region gitcommitDiff start=/\%(^diff --\%(git\|cc\|combined\) \)\@=/ end=/^$\|^#\@=/ contains=@gitcommitDiff
20
21syn match   gitcommitFirstLine	"\%^[^#].*"  nextgroup=gitcommitBlank skipnl
22syn match   gitcommitSummary	"^.\{0,50\}" contained containedin=gitcommitFirstLine nextgroup=gitcommitOverflow contains=@Spell
23syn match   gitcommitOverflow	".*" contained contains=@Spell
24syn match   gitcommitBlank	"^[^#].*" contained contains=@Spell
25syn match   gitcommitComment	"^#.*"
26syn match   gitcommitHead	"^\%(#   .*\n\)\+#$" contained transparent
27syn match   gitcommitOnBranch	"\%(^# \)\@<=On branch" contained containedin=gitcommitComment nextgroup=gitcommitBranch skipwhite
28syn match   gitcommitOnBranch	"\%(^# \)\@<=Your branch .\{-\} '" contained containedin=gitcommitComment nextgroup=gitcommitBranch skipwhite
29syn match   gitcommitBranch	"[^ \t']\+" contained
30syn match   gitcommitNoBranch	"\%(^# \)\@<=Not currently on any branch." contained containedin=gitcommitComment
31syn match   gitcommitHeader	"\%(^# \)\@<=.*:$"	contained containedin=gitcommitComment
32syn region  gitcommitAuthor	matchgroup=gitCommitHeader start=/\%(^# \)\@<=\%(Author\|Committer\):/ end=/$/ keepend oneline contained containedin=gitcommitComment transparent
33syn match   gitcommitNoChanges	"\%(^# \)\@<=No changes$" contained containedin=gitcommitComment
34
35syn region  gitcommitUntracked	start=/^# Untracked files:/ end=/^#$\|^#\@!/ contains=gitcommitHeader,gitcommitHead,gitcommitUntrackedFile fold
36syn match   gitcommitUntrackedFile  "\t\@<=.*"	contained
37
38syn region  gitcommitDiscarded	start=/^# Changed but not updated:/ end=/^#$\|^#\@!/ contains=gitcommitHeader,gitcommitHead,gitcommitDiscardedType fold
39syn region  gitcommitSelected	start=/^# Changes to be committed:/ end=/^#$\|^#\@!/ contains=gitcommitHeader,gitcommitHead,gitcommitSelectedType fold
40syn region  gitcommitUnmerged	start=/^# Unmerged paths:/ end=/^#$\|^#\@!/ contains=gitcommitHeader,gitcommitHead,gitcommitUnmergedType fold
41
42syn match   gitcommitDiscardedType	"\t\@<=[a-z][a-z ]*[a-z]: "he=e-2	contained containedin=gitcommitComment nextgroup=gitcommitDiscardedFile skipwhite
43syn match   gitcommitSelectedType	"\t\@<=[a-z][a-z ]*[a-z]: "he=e-2	contained containedin=gitcommitComment nextgroup=gitcommitSelectedFile skipwhite
44syn match   gitcommitUnmergedType	"\t\@<=[a-z][a-z ]*[a-z]: "he=e-2	contained containedin=gitcommitComment nextgroup=gitcommitUnmergedFile skipwhite
45syn match   gitcommitDiscardedFile	".\{-\}\%($\| -> \)\@=" contained nextgroup=gitcommitDiscardedArrow
46syn match   gitcommitSelectedFile	".\{-\}\%($\| -> \)\@=" contained nextgroup=gitcommitSelectedArrow
47syn match   gitcommitUnmergedFile	".\{-\}\%($\| -> \)\@=" contained nextgroup=gitcommitSelectedArrow
48syn match   gitcommitDiscardedArrow	" -> " contained nextgroup=gitcommitDiscardedFile
49syn match   gitcommitSelectedArrow	" -> " contained nextgroup=gitcommitSelectedFile
50syn match   gitcommitUnmergedArrow	" -> " contained nextgroup=gitcommitSelectedFile
51
52syn match   gitcommitWarning		"\%^[^#].*: needs merge$" nextgroup=gitcommitWarning skipnl
53syn match   gitcommitWarning		"^[^#].*: needs merge$" nextgroup=gitcommitWarning skipnl contained
54syn match   gitcommitWarning		"^\%(no changes added to commit\|nothing \%(added \)\=to commit\)\>.*\%$"
55
56hi def link gitcommitSummary		Keyword
57hi def link gitcommitComment		Comment
58hi def link gitcommitUntracked		gitcommitComment
59hi def link gitcommitDiscarded		gitcommitComment
60hi def link gitcommitSelected		gitcommitComment
61hi def link gitcommitUnmerged		gitcommitComment
62hi def link gitcommitOnBranch		Comment
63hi def link gitcommitBranch		Special
64hi def link gitcommitNoBranch		gitCommitBranch
65hi def link gitcommitDiscardedType	gitcommitType
66hi def link gitcommitSelectedType	gitcommitType
67hi def link gitcommitUnmergedType	gitcommitType
68hi def link gitcommitType		Type
69hi def link gitcommitNoChanges		gitcommitHeader
70hi def link gitcommitHeader		PreProc
71hi def link gitcommitUntrackedFile	gitcommitFile
72hi def link gitcommitDiscardedFile	gitcommitFile
73hi def link gitcommitSelectedFile	gitcommitFile
74hi def link gitcommitUnmergedFile	gitcommitFile
75hi def link gitcommitFile		Constant
76hi def link gitcommitDiscardedArrow	gitcommitArrow
77hi def link gitcommitSelectedArrow	gitcommitArrow
78hi def link gitcommitUnmergedArrow	gitcommitArrow
79hi def link gitcommitArrow		gitcommitComment
80"hi def link gitcommitOverflow		Error
81hi def link gitcommitBlank		Error
82
83let b:current_syntax = "gitcommit"
84