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