blob: 5e0642fbcc74132d75381bb3d15d1a0df317e62c [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 Moolenaar89bcfda2016-08-30 23:26:57 +02005" Last Change: 2016 Aug 29
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
Bram Moolenaar89bcfda2016-08-30 23:26:57 +020042
43syn match gitcommitDiscardedType "\t\@<=[[:lower:]][^:]*[[:lower:]]: "he=e-2 contained containedin=gitcommitComment nextgroup=gitcommitDiscardedFile skipwhite
44syn match gitcommitSelectedType "\t\@<=[[:lower:]][^:]*[[:lower:]]: "he=e-2 contained containedin=gitcommitComment nextgroup=gitcommitSelectedFile skipwhite
45syn match gitcommitUnmergedType "\t\@<=[[:lower:]][^:]*[[:lower:]]: "he=e-2 contained containedin=gitcommitComment nextgroup=gitcommitUnmergedFile skipwhite
Bram Moolenaar8c8de832008-06-24 22:58:06 +000046syn match gitcommitDiscardedFile ".\{-\}\%($\| -> \)\@=" contained nextgroup=gitcommitDiscardedArrow
47syn match gitcommitSelectedFile ".\{-\}\%($\| -> \)\@=" contained nextgroup=gitcommitSelectedArrow
Bram Moolenaar5c736222010-01-06 20:54:52 +010048syn match gitcommitUnmergedFile ".\{-\}\%($\| -> \)\@=" contained nextgroup=gitcommitSelectedArrow
Bram Moolenaar8c8de832008-06-24 22:58:06 +000049syn match gitcommitDiscardedArrow " -> " contained nextgroup=gitcommitDiscardedFile
50syn match gitcommitSelectedArrow " -> " contained nextgroup=gitcommitSelectedFile
Bram Moolenaar5c736222010-01-06 20:54:52 +010051syn match gitcommitUnmergedArrow " -> " contained nextgroup=gitcommitSelectedFile
52
53syn match gitcommitWarning "\%^[^#].*: needs merge$" nextgroup=gitcommitWarning skipnl
54syn match gitcommitWarning "^[^#].*: needs merge$" nextgroup=gitcommitWarning skipnl contained
55syn match gitcommitWarning "^\%(no changes added to commit\|nothing \%(added \)\=to commit\)\>.*\%$"
Bram Moolenaar8c8de832008-06-24 22:58:06 +000056
57hi def link gitcommitSummary Keyword
58hi def link gitcommitComment Comment
59hi def link gitcommitUntracked gitcommitComment
60hi def link gitcommitDiscarded gitcommitComment
61hi def link gitcommitSelected gitcommitComment
Bram Moolenaar5c736222010-01-06 20:54:52 +010062hi def link gitcommitUnmerged gitcommitComment
Bram Moolenaar8c8de832008-06-24 22:58:06 +000063hi def link gitcommitOnBranch Comment
64hi def link gitcommitBranch Special
Bram Moolenaar5c736222010-01-06 20:54:52 +010065hi def link gitcommitNoBranch gitCommitBranch
Bram Moolenaar8c8de832008-06-24 22:58:06 +000066hi def link gitcommitDiscardedType gitcommitType
67hi def link gitcommitSelectedType gitcommitType
Bram Moolenaar5c736222010-01-06 20:54:52 +010068hi def link gitcommitUnmergedType gitcommitType
Bram Moolenaar8c8de832008-06-24 22:58:06 +000069hi def link gitcommitType Type
Bram Moolenaar5c736222010-01-06 20:54:52 +010070hi def link gitcommitNoChanges gitcommitHeader
Bram Moolenaar8c8de832008-06-24 22:58:06 +000071hi def link gitcommitHeader PreProc
72hi def link gitcommitUntrackedFile gitcommitFile
73hi def link gitcommitDiscardedFile gitcommitFile
74hi def link gitcommitSelectedFile gitcommitFile
Bram Moolenaar5c736222010-01-06 20:54:52 +010075hi def link gitcommitUnmergedFile gitcommitFile
Bram Moolenaar8c8de832008-06-24 22:58:06 +000076hi def link gitcommitFile Constant
77hi def link gitcommitDiscardedArrow gitcommitArrow
78hi def link gitcommitSelectedArrow gitcommitArrow
Bram Moolenaar5c736222010-01-06 20:54:52 +010079hi def link gitcommitUnmergedArrow gitcommitArrow
Bram Moolenaar8c8de832008-06-24 22:58:06 +000080hi def link gitcommitArrow gitcommitComment
81"hi def link gitcommitOverflow Error
82hi def link gitcommitBlank Error
83
84let b:current_syntax = "gitcommit"