blob: 12db0a42a0bed5104b73078ee20391874b9fd60d [file] [log] [blame]
Bram Moolenaar8c8de832008-06-24 22:58:06 +00001" Vim syntax file
2" Language: git commit file
Bram Moolenaar5c736222010-01-06 20:54:52 +01003" Maintainer: Tim Pope <vimNOSPAM@tpope.org>
Bram Moolenaar8c8de832008-06-24 22:58:06 +00004" Filenames: *.git/COMMIT_EDITMSG
Bram Moolenaar5c736222010-01-06 20:54:52 +01005" Last Change: 2009 Dec 24
Bram Moolenaar8c8de832008-06-24 22:58:06 +00006
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
Bram Moolenaar5c736222010-01-06 20:54:52 +010019syn region gitcommitDiff start=/\%(^diff --\%(git\|cc\|combined\) \)\@=/ end=/^$\|^#\@=/ contains=@gitcommitDiff
Bram Moolenaar8c8de832008-06-24 22:58:06 +000020
21syn match gitcommitFirstLine "\%^[^#].*" nextgroup=gitcommitBlank skipnl
Bram Moolenaar5c736222010-01-06 20:54:52 +010022syn match gitcommitSummary "^.\{0,50\}" contained containedin=gitcommitFirstLine nextgroup=gitcommitOverflow contains=@Spell
Bram Moolenaar8c8de832008-06-24 22:58:06 +000023syn match gitcommitOverflow ".*" contained contains=@Spell
24syn match gitcommitBlank "^[^#].*" contained contains=@Spell
25syn match gitcommitComment "^#.*"
Bram Moolenaar5c736222010-01-06 20:54:52 +010026syn match gitcommitHead "^\%(# .*\n\)\+#$" contained transparent
Bram Moolenaar8c8de832008-06-24 22:58:06 +000027syn match gitcommitOnBranch "\%(^# \)\@<=On branch" contained containedin=gitcommitComment nextgroup=gitcommitBranch skipwhite
Bram Moolenaar5c736222010-01-06 20:54:52 +010028syn 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
Bram Moolenaar8c8de832008-06-24 22:58:06 +000031syn match gitcommitHeader "\%(^# \)\@<=.*:$" contained containedin=gitcommitComment
Bram Moolenaar5c736222010-01-06 20:54:52 +010032syn region gitcommitAuthor matchgroup=gitCommitHeader start=/\%(^# \)\@<=Author:/ end=/$/ keepend oneline contained containedin=gitcommitComment transparent
33syn match gitcommitNoChanges "\%(^# \)\@<=No changes$" contained containedin=gitcommitComment
Bram Moolenaar8c8de832008-06-24 22:58:06 +000034
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
Bram Moolenaar5c736222010-01-06 20:54:52 +010040syn region gitcommitUnmerged start=/^# Unmerged paths:/ end=/^#$\|^#\@!/ contains=gitcommitHeader,gitcommitHead,gitcommitUnmergedType fold
Bram Moolenaar8c8de832008-06-24 22:58:06 +000041
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
Bram Moolenaar5c736222010-01-06 20:54:52 +010044syn match gitcommitUnmergedType "\t\@<=[a-z][a-z ]*[a-z]: "he=e-2 contained containedin=gitcommitComment nextgroup=gitcommitUnmergedFile skipwhite
Bram Moolenaar8c8de832008-06-24 22:58:06 +000045syn match gitcommitDiscardedFile ".\{-\}\%($\| -> \)\@=" contained nextgroup=gitcommitDiscardedArrow
46syn match gitcommitSelectedFile ".\{-\}\%($\| -> \)\@=" contained nextgroup=gitcommitSelectedArrow
Bram Moolenaar5c736222010-01-06 20:54:52 +010047syn match gitcommitUnmergedFile ".\{-\}\%($\| -> \)\@=" contained nextgroup=gitcommitSelectedArrow
Bram Moolenaar8c8de832008-06-24 22:58:06 +000048syn match gitcommitDiscardedArrow " -> " contained nextgroup=gitcommitDiscardedFile
49syn match gitcommitSelectedArrow " -> " contained nextgroup=gitcommitSelectedFile
Bram Moolenaar5c736222010-01-06 20:54:52 +010050syn 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\)\>.*\%$"
Bram Moolenaar8c8de832008-06-24 22:58:06 +000055
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
Bram Moolenaar5c736222010-01-06 20:54:52 +010061hi def link gitcommitUnmerged gitcommitComment
Bram Moolenaar8c8de832008-06-24 22:58:06 +000062hi def link gitcommitOnBranch Comment
63hi def link gitcommitBranch Special
Bram Moolenaar5c736222010-01-06 20:54:52 +010064hi def link gitcommitNoBranch gitCommitBranch
Bram Moolenaar8c8de832008-06-24 22:58:06 +000065hi def link gitcommitDiscardedType gitcommitType
66hi def link gitcommitSelectedType gitcommitType
Bram Moolenaar5c736222010-01-06 20:54:52 +010067hi def link gitcommitUnmergedType gitcommitType
Bram Moolenaar8c8de832008-06-24 22:58:06 +000068hi def link gitcommitType Type
Bram Moolenaar5c736222010-01-06 20:54:52 +010069hi def link gitcommitNoChanges gitcommitHeader
Bram Moolenaar8c8de832008-06-24 22:58:06 +000070hi def link gitcommitHeader PreProc
71hi def link gitcommitUntrackedFile gitcommitFile
72hi def link gitcommitDiscardedFile gitcommitFile
73hi def link gitcommitSelectedFile gitcommitFile
Bram Moolenaar5c736222010-01-06 20:54:52 +010074hi def link gitcommitUnmergedFile gitcommitFile
Bram Moolenaar8c8de832008-06-24 22:58:06 +000075hi def link gitcommitFile Constant
76hi def link gitcommitDiscardedArrow gitcommitArrow
77hi def link gitcommitSelectedArrow gitcommitArrow
Bram Moolenaar5c736222010-01-06 20:54:52 +010078hi def link gitcommitUnmergedArrow gitcommitArrow
Bram Moolenaar8c8de832008-06-24 22:58:06 +000079hi def link gitcommitArrow gitcommitComment
80"hi def link gitcommitOverflow Error
81hi def link gitcommitBlank Error
82
83let b:current_syntax = "gitcommit"