blob: 83cd4733f45f2b112c61b3c05bc1b33109a9d1e6 [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 Moolenaar53bfca22012-04-13 23:04:47 +02005" Last Change: 2012 April 7
Bram Moolenaar8c8de832008-06-24 22:58:06 +00006
7if exists("b:current_syntax")
Bram Moolenaar7a329912010-05-21 12:05:36 +02008 finish
Bram Moolenaar8c8de832008-06-24 22:58:06 +00009endif
10
11syn case match
12syn sync minlines=50
13
14if has("spell")
Bram Moolenaar7a329912010-05-21 12:05:36 +020015 syn spell toplevel
Bram Moolenaar8c8de832008-06-24 22:58:06 +000016endif
17
18syn include @gitcommitDiff syntax/diff.vim
Bram Moolenaar53bfca22012-04-13 23:04:47 +020019syn region gitcommitDiff start=/\%(^diff --\%(git\|cc\|combined\) \)\@=/ end=/^\%(diff --\|$\|#\)\@=/ fold 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
Bram Moolenaar53bfca22012-04-13 23:04:47 +020029syn match gitcommitBranch "[^ ']\+" contained
Bram Moolenaar5c736222010-01-06 20:54:52 +010030syn match gitcommitNoBranch "\%(^# \)\@<=Not currently on any branch." contained containedin=gitcommitComment
Bram Moolenaar8c8de832008-06-24 22:58:06 +000031syn match gitcommitHeader "\%(^# \)\@<=.*:$" contained containedin=gitcommitComment
Bram Moolenaar7a329912010-05-21 12:05:36 +020032syn region gitcommitAuthor matchgroup=gitCommitHeader start=/\%(^# \)\@<=\%(Author\|Committer\):/ end=/$/ keepend oneline contained containedin=gitcommitComment transparent
Bram Moolenaar5c736222010-01-06 20:54:52 +010033syn 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
Bram Moolenaar53bfca22012-04-13 23:04:47 +020038syn region gitcommitDiscarded start=/^# Change\%(s not staged for commit\|d but not updated\):/ end=/^#$\|^#\@!/ contains=gitcommitHeader,gitcommitHead,gitcommitDiscardedType fold
Bram Moolenaar8c8de832008-06-24 22:58:06 +000039syn 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"