Bram Moolenaar | 8c8de83 | 2008-06-24 22:58:06 +0000 | [diff] [blame] | 1 | " Vim syntax file |
| 2 | " Language: git commit file |
Bram Moolenaar | 5c73622 | 2010-01-06 20:54:52 +0100 | [diff] [blame] | 3 | " Maintainer: Tim Pope <vimNOSPAM@tpope.org> |
Bram Moolenaar | 8c8de83 | 2008-06-24 22:58:06 +0000 | [diff] [blame] | 4 | " Filenames: *.git/COMMIT_EDITMSG |
Bram Moolenaar | 543b7ef | 2013-06-01 14:50:56 +0200 | [diff] [blame] | 5 | " Last Change: 2013 May 30 |
Bram Moolenaar | 8c8de83 | 2008-06-24 22:58:06 +0000 | [diff] [blame] | 6 | |
| 7 | if exists("b:current_syntax") |
Bram Moolenaar | 7a32991 | 2010-05-21 12:05:36 +0200 | [diff] [blame] | 8 | finish |
Bram Moolenaar | 8c8de83 | 2008-06-24 22:58:06 +0000 | [diff] [blame] | 9 | endif |
| 10 | |
| 11 | syn case match |
| 12 | syn sync minlines=50 |
| 13 | |
| 14 | if has("spell") |
Bram Moolenaar | 7a32991 | 2010-05-21 12:05:36 +0200 | [diff] [blame] | 15 | syn spell toplevel |
Bram Moolenaar | 8c8de83 | 2008-06-24 22:58:06 +0000 | [diff] [blame] | 16 | endif |
| 17 | |
| 18 | syn include @gitcommitDiff syntax/diff.vim |
Bram Moolenaar | 53bfca2 | 2012-04-13 23:04:47 +0200 | [diff] [blame] | 19 | syn region gitcommitDiff start=/\%(^diff --\%(git\|cc\|combined\) \)\@=/ end=/^\%(diff --\|$\|#\)\@=/ fold contains=@gitcommitDiff |
Bram Moolenaar | 8c8de83 | 2008-06-24 22:58:06 +0000 | [diff] [blame] | 20 | |
| 21 | syn match gitcommitFirstLine "\%^[^#].*" nextgroup=gitcommitBlank skipnl |
Bram Moolenaar | 5c73622 | 2010-01-06 20:54:52 +0100 | [diff] [blame] | 22 | syn match gitcommitSummary "^.\{0,50\}" contained containedin=gitcommitFirstLine nextgroup=gitcommitOverflow contains=@Spell |
Bram Moolenaar | 8c8de83 | 2008-06-24 22:58:06 +0000 | [diff] [blame] | 23 | syn match gitcommitOverflow ".*" contained contains=@Spell |
| 24 | syn match gitcommitBlank "^[^#].*" contained contains=@Spell |
| 25 | syn match gitcommitComment "^#.*" |
Bram Moolenaar | 5c73622 | 2010-01-06 20:54:52 +0100 | [diff] [blame] | 26 | syn match gitcommitHead "^\%(# .*\n\)\+#$" contained transparent |
Bram Moolenaar | 8c8de83 | 2008-06-24 22:58:06 +0000 | [diff] [blame] | 27 | syn match gitcommitOnBranch "\%(^# \)\@<=On branch" contained containedin=gitcommitComment nextgroup=gitcommitBranch skipwhite |
Bram Moolenaar | 5c73622 | 2010-01-06 20:54:52 +0100 | [diff] [blame] | 28 | syn match gitcommitOnBranch "\%(^# \)\@<=Your branch .\{-\} '" contained containedin=gitcommitComment nextgroup=gitcommitBranch skipwhite |
Bram Moolenaar | 53bfca2 | 2012-04-13 23:04:47 +0200 | [diff] [blame] | 29 | syn match gitcommitBranch "[^ ']\+" contained |
Bram Moolenaar | 5c73622 | 2010-01-06 20:54:52 +0100 | [diff] [blame] | 30 | syn match gitcommitNoBranch "\%(^# \)\@<=Not currently on any branch." contained containedin=gitcommitComment |
Bram Moolenaar | 8c8de83 | 2008-06-24 22:58:06 +0000 | [diff] [blame] | 31 | syn match gitcommitHeader "\%(^# \)\@<=.*:$" contained containedin=gitcommitComment |
Bram Moolenaar | 7a32991 | 2010-05-21 12:05:36 +0200 | [diff] [blame] | 32 | syn region gitcommitAuthor matchgroup=gitCommitHeader start=/\%(^# \)\@<=\%(Author\|Committer\):/ end=/$/ keepend oneline contained containedin=gitcommitComment transparent |
Bram Moolenaar | 5c73622 | 2010-01-06 20:54:52 +0100 | [diff] [blame] | 33 | syn match gitcommitNoChanges "\%(^# \)\@<=No changes$" contained containedin=gitcommitComment |
Bram Moolenaar | 8c8de83 | 2008-06-24 22:58:06 +0000 | [diff] [blame] | 34 | |
| 35 | syn region gitcommitUntracked start=/^# Untracked files:/ end=/^#$\|^#\@!/ contains=gitcommitHeader,gitcommitHead,gitcommitUntrackedFile fold |
| 36 | syn match gitcommitUntrackedFile "\t\@<=.*" contained |
| 37 | |
Bram Moolenaar | 53bfca2 | 2012-04-13 23:04:47 +0200 | [diff] [blame] | 38 | syn region gitcommitDiscarded start=/^# Change\%(s not staged for commit\|d but not updated\):/ end=/^#$\|^#\@!/ contains=gitcommitHeader,gitcommitHead,gitcommitDiscardedType fold |
Bram Moolenaar | 8c8de83 | 2008-06-24 22:58:06 +0000 | [diff] [blame] | 39 | syn region gitcommitSelected start=/^# Changes to be committed:/ end=/^#$\|^#\@!/ contains=gitcommitHeader,gitcommitHead,gitcommitSelectedType fold |
Bram Moolenaar | 5c73622 | 2010-01-06 20:54:52 +0100 | [diff] [blame] | 40 | syn region gitcommitUnmerged start=/^# Unmerged paths:/ end=/^#$\|^#\@!/ contains=gitcommitHeader,gitcommitHead,gitcommitUnmergedType fold |
Bram Moolenaar | 8c8de83 | 2008-06-24 22:58:06 +0000 | [diff] [blame] | 41 | |
| 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 |
Bram Moolenaar | 5c73622 | 2010-01-06 20:54:52 +0100 | [diff] [blame] | 44 | syn match gitcommitUnmergedType "\t\@<=[a-z][a-z ]*[a-z]: "he=e-2 contained containedin=gitcommitComment nextgroup=gitcommitUnmergedFile skipwhite |
Bram Moolenaar | 8c8de83 | 2008-06-24 22:58:06 +0000 | [diff] [blame] | 45 | syn match gitcommitDiscardedFile ".\{-\}\%($\| -> \)\@=" contained nextgroup=gitcommitDiscardedArrow |
| 46 | syn match gitcommitSelectedFile ".\{-\}\%($\| -> \)\@=" contained nextgroup=gitcommitSelectedArrow |
Bram Moolenaar | 5c73622 | 2010-01-06 20:54:52 +0100 | [diff] [blame] | 47 | syn match gitcommitUnmergedFile ".\{-\}\%($\| -> \)\@=" contained nextgroup=gitcommitSelectedArrow |
Bram Moolenaar | 8c8de83 | 2008-06-24 22:58:06 +0000 | [diff] [blame] | 48 | syn match gitcommitDiscardedArrow " -> " contained nextgroup=gitcommitDiscardedFile |
| 49 | syn match gitcommitSelectedArrow " -> " contained nextgroup=gitcommitSelectedFile |
Bram Moolenaar | 5c73622 | 2010-01-06 20:54:52 +0100 | [diff] [blame] | 50 | syn match gitcommitUnmergedArrow " -> " contained nextgroup=gitcommitSelectedFile |
| 51 | |
| 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\)\>.*\%$" |
Bram Moolenaar | 8c8de83 | 2008-06-24 22:58:06 +0000 | [diff] [blame] | 55 | |
| 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 |
Bram Moolenaar | 5c73622 | 2010-01-06 20:54:52 +0100 | [diff] [blame] | 61 | hi def link gitcommitUnmerged gitcommitComment |
Bram Moolenaar | 8c8de83 | 2008-06-24 22:58:06 +0000 | [diff] [blame] | 62 | hi def link gitcommitOnBranch Comment |
| 63 | hi def link gitcommitBranch Special |
Bram Moolenaar | 5c73622 | 2010-01-06 20:54:52 +0100 | [diff] [blame] | 64 | hi def link gitcommitNoBranch gitCommitBranch |
Bram Moolenaar | 8c8de83 | 2008-06-24 22:58:06 +0000 | [diff] [blame] | 65 | hi def link gitcommitDiscardedType gitcommitType |
| 66 | hi def link gitcommitSelectedType gitcommitType |
Bram Moolenaar | 5c73622 | 2010-01-06 20:54:52 +0100 | [diff] [blame] | 67 | hi def link gitcommitUnmergedType gitcommitType |
Bram Moolenaar | 8c8de83 | 2008-06-24 22:58:06 +0000 | [diff] [blame] | 68 | hi def link gitcommitType Type |
Bram Moolenaar | 5c73622 | 2010-01-06 20:54:52 +0100 | [diff] [blame] | 69 | hi def link gitcommitNoChanges gitcommitHeader |
Bram Moolenaar | 8c8de83 | 2008-06-24 22:58:06 +0000 | [diff] [blame] | 70 | hi def link gitcommitHeader PreProc |
| 71 | hi def link gitcommitUntrackedFile gitcommitFile |
| 72 | hi def link gitcommitDiscardedFile gitcommitFile |
| 73 | hi def link gitcommitSelectedFile gitcommitFile |
Bram Moolenaar | 5c73622 | 2010-01-06 20:54:52 +0100 | [diff] [blame] | 74 | hi def link gitcommitUnmergedFile gitcommitFile |
Bram Moolenaar | 8c8de83 | 2008-06-24 22:58:06 +0000 | [diff] [blame] | 75 | hi def link gitcommitFile Constant |
| 76 | hi def link gitcommitDiscardedArrow gitcommitArrow |
| 77 | hi def link gitcommitSelectedArrow gitcommitArrow |
Bram Moolenaar | 5c73622 | 2010-01-06 20:54:52 +0100 | [diff] [blame] | 78 | hi def link gitcommitUnmergedArrow gitcommitArrow |
Bram Moolenaar | 8c8de83 | 2008-06-24 22:58:06 +0000 | [diff] [blame] | 79 | hi def link gitcommitArrow gitcommitComment |
| 80 | "hi def link gitcommitOverflow Error |
| 81 | hi def link gitcommitBlank Error |
| 82 | |
| 83 | let b:current_syntax = "gitcommit" |