blob: 63b1ce920f8a6efae957db5d3e620c7c3336ef58 [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 Moolenaarc08ee742019-12-05 22:47:25 +01005" Last Change: 2019 Dec 05
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
Bram Moolenaarc08ee742019-12-05 22:47:25 +010021syn match gitcommitSummary "^.*\%<51v." contained containedin=gitcommitFirstLine nextgroup=gitcommitOverflow contains=@Spell
Bram Moolenaar8c8de832008-06-24 22:58:06 +000022syn match gitcommitOverflow ".*" contained contains=@Spell
23syn match gitcommitBlank "^[^#].*" contained contains=@Spell
Bram Moolenaarc08ee742019-12-05 22:47:25 +010024
25if get(g:, "gitcommit_cleanup") is# "scissors"
26 syn match gitcommitFirstLine "\%^.*" nextgroup=gitcommitBlank skipnl
27 syn region gitcommitComment start=/^# -\+ >8 -\+$/ end=/\%$/ contains=gitcommitDiff
28else
29 syn match gitcommitFirstLine "\%^[^#].*" nextgroup=gitcommitBlank skipnl
30 syn match gitcommitComment "^#.*"
31endif
32
Bram Moolenaar5c736222010-01-06 20:54:52 +010033syn match gitcommitHead "^\%(# .*\n\)\+#$" contained transparent
Bram Moolenaar8c8de832008-06-24 22:58:06 +000034syn match gitcommitOnBranch "\%(^# \)\@<=On branch" contained containedin=gitcommitComment nextgroup=gitcommitBranch skipwhite
Bram Moolenaar5c736222010-01-06 20:54:52 +010035syn match gitcommitOnBranch "\%(^# \)\@<=Your branch .\{-\} '" contained containedin=gitcommitComment nextgroup=gitcommitBranch skipwhite
Bram Moolenaar53bfca22012-04-13 23:04:47 +020036syn match gitcommitBranch "[^ ']\+" contained
Bram Moolenaar5c736222010-01-06 20:54:52 +010037syn match gitcommitNoBranch "\%(^# \)\@<=Not currently on any branch." contained containedin=gitcommitComment
Bram Moolenaar8c8de832008-06-24 22:58:06 +000038syn match gitcommitHeader "\%(^# \)\@<=.*:$" contained containedin=gitcommitComment
Bram Moolenaar7a329912010-05-21 12:05:36 +020039syn region gitcommitAuthor matchgroup=gitCommitHeader start=/\%(^# \)\@<=\%(Author\|Committer\):/ end=/$/ keepend oneline contained containedin=gitcommitComment transparent
Bram Moolenaar5c736222010-01-06 20:54:52 +010040syn match gitcommitNoChanges "\%(^# \)\@<=No changes$" contained containedin=gitcommitComment
Bram Moolenaar8c8de832008-06-24 22:58:06 +000041
42syn region gitcommitUntracked start=/^# Untracked files:/ end=/^#$\|^#\@!/ contains=gitcommitHeader,gitcommitHead,gitcommitUntrackedFile fold
43syn match gitcommitUntrackedFile "\t\@<=.*" contained
44
Bram Moolenaar53bfca22012-04-13 23:04:47 +020045syn 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 +000046syn region gitcommitSelected start=/^# Changes to be committed:/ end=/^#$\|^#\@!/ contains=gitcommitHeader,gitcommitHead,gitcommitSelectedType fold
Bram Moolenaar5c736222010-01-06 20:54:52 +010047syn region gitcommitUnmerged start=/^# Unmerged paths:/ end=/^#$\|^#\@!/ contains=gitcommitHeader,gitcommitHead,gitcommitUnmergedType fold
Bram Moolenaar8c8de832008-06-24 22:58:06 +000048
Bram Moolenaar89bcfda2016-08-30 23:26:57 +020049
50syn match gitcommitDiscardedType "\t\@<=[[:lower:]][^:]*[[:lower:]]: "he=e-2 contained containedin=gitcommitComment nextgroup=gitcommitDiscardedFile skipwhite
51syn match gitcommitSelectedType "\t\@<=[[:lower:]][^:]*[[:lower:]]: "he=e-2 contained containedin=gitcommitComment nextgroup=gitcommitSelectedFile skipwhite
52syn match gitcommitUnmergedType "\t\@<=[[:lower:]][^:]*[[:lower:]]: "he=e-2 contained containedin=gitcommitComment nextgroup=gitcommitUnmergedFile skipwhite
Bram Moolenaar8c8de832008-06-24 22:58:06 +000053syn match gitcommitDiscardedFile ".\{-\}\%($\| -> \)\@=" contained nextgroup=gitcommitDiscardedArrow
54syn match gitcommitSelectedFile ".\{-\}\%($\| -> \)\@=" contained nextgroup=gitcommitSelectedArrow
Bram Moolenaar5c736222010-01-06 20:54:52 +010055syn match gitcommitUnmergedFile ".\{-\}\%($\| -> \)\@=" contained nextgroup=gitcommitSelectedArrow
Bram Moolenaar8c8de832008-06-24 22:58:06 +000056syn match gitcommitDiscardedArrow " -> " contained nextgroup=gitcommitDiscardedFile
57syn match gitcommitSelectedArrow " -> " contained nextgroup=gitcommitSelectedFile
Bram Moolenaar5c736222010-01-06 20:54:52 +010058syn match gitcommitUnmergedArrow " -> " contained nextgroup=gitcommitSelectedFile
59
60syn match gitcommitWarning "\%^[^#].*: needs merge$" nextgroup=gitcommitWarning skipnl
61syn match gitcommitWarning "^[^#].*: needs merge$" nextgroup=gitcommitWarning skipnl contained
62syn match gitcommitWarning "^\%(no changes added to commit\|nothing \%(added \)\=to commit\)\>.*\%$"
Bram Moolenaar8c8de832008-06-24 22:58:06 +000063
64hi def link gitcommitSummary Keyword
65hi def link gitcommitComment Comment
66hi def link gitcommitUntracked gitcommitComment
67hi def link gitcommitDiscarded gitcommitComment
68hi def link gitcommitSelected gitcommitComment
Bram Moolenaar5c736222010-01-06 20:54:52 +010069hi def link gitcommitUnmerged gitcommitComment
Bram Moolenaar8c8de832008-06-24 22:58:06 +000070hi def link gitcommitOnBranch Comment
71hi def link gitcommitBranch Special
Bram Moolenaar5c736222010-01-06 20:54:52 +010072hi def link gitcommitNoBranch gitCommitBranch
Bram Moolenaar8c8de832008-06-24 22:58:06 +000073hi def link gitcommitDiscardedType gitcommitType
74hi def link gitcommitSelectedType gitcommitType
Bram Moolenaar5c736222010-01-06 20:54:52 +010075hi def link gitcommitUnmergedType gitcommitType
Bram Moolenaar8c8de832008-06-24 22:58:06 +000076hi def link gitcommitType Type
Bram Moolenaar5c736222010-01-06 20:54:52 +010077hi def link gitcommitNoChanges gitcommitHeader
Bram Moolenaar8c8de832008-06-24 22:58:06 +000078hi def link gitcommitHeader PreProc
79hi def link gitcommitUntrackedFile gitcommitFile
80hi def link gitcommitDiscardedFile gitcommitFile
81hi def link gitcommitSelectedFile gitcommitFile
Bram Moolenaar5c736222010-01-06 20:54:52 +010082hi def link gitcommitUnmergedFile gitcommitFile
Bram Moolenaar8c8de832008-06-24 22:58:06 +000083hi def link gitcommitFile Constant
84hi def link gitcommitDiscardedArrow gitcommitArrow
85hi def link gitcommitSelectedArrow gitcommitArrow
Bram Moolenaar5c736222010-01-06 20:54:52 +010086hi def link gitcommitUnmergedArrow gitcommitArrow
Bram Moolenaar8c8de832008-06-24 22:58:06 +000087hi def link gitcommitArrow gitcommitComment
88"hi def link gitcommitOverflow Error
89hi def link gitcommitBlank Error
90
91let b:current_syntax = "gitcommit"