robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
419f038727
master
1" Vim syntax file 2" Language: git commit file 3" Maintainer: Tim Pope <vimNOSPAM@tpope.org> 4" Filenames: *.git/COMMIT_EDITMSG 5" Last Change: 2023 Dec 28 6 7if exists ( "b:current_syntax" ) 8finish 9endif 10 11scriptencoding utf-8 12 13syn case match 14syn sync minlines= 50 15syn sync linebreaks= 1 16 17if has ( "spell" ) 18syn spell toplevel 19endif 20 21syn include @gitcommitDiff syntax/diff.vim 22syn region gitcommitDiff start = /\%(^diff --\%(git\|cc\|combined\) \)\@= /end = /^\%(diff --\|$\|@@\@!\| [ ^[:alnum: ] \ +-]\S\@!\)\@= /fold contains = @gitcommitDiff 23 24if get ( g:, 'gitcommit_summary_length' ) < 0 25syn match gitcommitSummary "^. * $ "contained containedin = gitcommitFirstLine nextgroup = gitcommitOverflow contains = @Spell 26elseif get ( g:, 'gitcommit_summary_length' , 1 ) > 0 27exe 'syn match gitcommitSummary "^.*\%<' . ( get ( g:, 'gitcommit_summary_length' , 50 ) + 1 ) . 'v." contained containedin=gitcommitFirstLine nextgroup=gitcommitOverflow contains=@Spell' 28endif 29syn match gitcommitOverflow ". * "contained contains = @Spell 30syn match gitcommitBlank "^.\+ "contained contains = @Spell 31syn match gitcommitFirstLine "\%^. * "nextgroup = gitcommitBlank , gitcommitComment skipnl 32 33let s: scissors = 0 34let s: l = search ( '^[#;@!$%^&|:] -\{24,\} >8 -\{24,\}$' , 'cnW' , '' , 100 ) 35if s: l == 0 36let s: l = line ( '$' ) 37elseif getline ( s: l )[ 0 ] !=# getline ( s: l - 1 )[ 0 ] 38let s: scissors = 1 39endif 40let s: comment = escape (( matchstr ( getline ( s: l ), '^[#;@!$%^&|:]\S\@!' ) . '#' )[ 0 ], '^$.*[]~\"/' ) 41 42if s: scissors 43let s: comment .= ' -\{24,\} >8 -\{24,\}$' 44exe 'syn region gitcommitComment start="^' . s: comment . '" end="\%$" contains=gitcommitDiff' 45else 46exe 'syn match gitcommitComment "^' . s: comment . '.*"' 47endif 48exe 'syn match gitcommitTrailers "\n\@<=\n\%([[:alnum:]-]\+\s*:.*\|(cherry picked from commit .*\)\%(\n\s.*\|\n[[:alnum:]-]\+\s*:.*\|\n(cherry picked from commit .*\)*\%(\n\n*\%(' . s: comment . '\)\|\n*\%$\)\@="' 49 50unlet s: l s: comment s: scissors 51 52syn match gitcommitTrailerToken "^ [ [:alnum: ] -]\+\s * : "contained containedin = gitcommitTrailers 53 54syn match gitcommitHash "\<\x\{40,}\> "contains = @NoSpell display 55syn match gitcommitOnBranch "\%(^. \)\@<=On branch "contained containedin = gitcommitComment nextgroup = gitcommitBranch skipwhite 56syn match gitcommitOnBranch "\%(^. \)\@<=Your branch .\{-\} ' "contained containedin = gitcommitComment nextgroup = gitcommitBranch skipwhite 57syn match gitcommitBranch "[ ^ ' ] \+ "contained 58syn match gitcommitNoBranch "\%(^. \)\@<=Not currently on any branch. "contained containedin = gitcommitComment 59syn match gitcommitHeader "\%(^. \)\@<=\S. * [ :: ] \%(\n^$\)\@!$ "contained containedin = gitcommitComment 60syn region gitcommitAuthor matchgroup = gitCommitHeader start = /\%(^. \)\@<=\%(Author\|Committer\|Date\): /end = /$ /keepend oneline contained containedin = gitcommitComment transparent 61syn match gitcommitHeader "\%(^. \)\@<=commit\%( \x\{40,\}$\)\@= "contained containedin = gitcommitComment nextgroup = gitcommitHash skipwhite 62syn match gitcommitNoChanges "\%(^. \)\@<=No changes$ "contained containedin = gitcommitComment 63 64syn match gitcommitType "\%(^.\t\)\@<= [ ^[:punct: ][ :space: ] ] [ ^/:: ] * [ ^[:punct: ][ :space: ] ] [ :: ] \ze "he= e-1contained containedin = gitcommitComment nextgroup = gitcommitFile skipwhite 65syn match gitcommitFile ".\{-\}\%($\| -> \)\@= "contained nextgroup = gitcommitArrow 66syn match gitcommitArrow "-> "contained nextgroup = gitcommitFile 67syn match gitcommitUntrackedFile "\%(^.\t\)\@<= [ ^::/ ] * \%(/. * \)\=$ "contained containedin = gitcommitComment 68 69syn region gitcommitUntracked start = /^\z(.\) Untracked files:$ /end = /^\z1\=$\|^\z1\@! /contains = gitcommitHeader containedin = gitcommitComment containedin = gitcommitComment contained transparent fold 70syn region gitcommitDiscarded start = /^\z(.\) Change\%(s not staged for commit\|d but not updated\):$ /end = /^\z1\=$\|^\z1\@! /contains = gitcommitHeader , gitcommitDiscardedType containedin = gitcommitComment containedin = gitcommitComment contained transparent fold 71syn region gitcommitSelected start = /^\z(.\) Changes to be committed:$ /end = /^\z1$\|^\z1\@! /contains = gitcommitHeader , gitcommitSelectedType containedin = gitcommitComment containedin = gitcommitComment contained transparent fold 72syn region gitcommitUnmerged start = /^\z(.\) Unmerged paths:$ /end = /^\z1\=$\|^\z1\@! /contains = gitcommitHeader , gitcommitUnmergedType containedin = gitcommitComment containedin = gitcommitComment contained transparent fold 73 74syn match gitcommitUntrackedFile "\%(^.\t\)\@<=. * "contained containedin = gitcommitUntracked 75 76syn match gitcommitDiscardedType "\%(^.\t\)\@<= [ ^[:punct: ][ :space: ] ] [ ^/:: ] * [ ^[:punct: ][ :space: ] ] [ :: ] \ze "he= e-1contained nextgroup = gitcommitDiscardedFile skipwhite 77syn match gitcommitSelectedType "\%(^.\t\)\@<= [ ^[:punct: ][ :space: ] ] [ ^/:: ] * [ ^[:punct: ][ :space: ] ] [ :: ] \ze "he= e-1contained nextgroup = gitcommitSelectedFile skipwhite 78syn match gitcommitUnmergedType "\%(^.\t\)\@<= [ ^[:punct: ][ :space: ] ] [ ^/:: ] * [ ^[:punct: ][ :space: ] ] [ :: ] \ze "he= e-1contained nextgroup = gitcommitUnmergedFile skipwhite 79syn match gitcommitDiscardedFile "\S.\{-\}\%($\| -> \)\@= "contained nextgroup = gitcommitDiscardedArrow 80syn match gitcommitSelectedFile "\S.\{-\}\%($\| -> \)\@= "contained nextgroup = gitcommitSelectedArrow 81syn match gitcommitUnmergedFile "\S.\{-\}\%($\| -> \)\@= "contained nextgroup = gitcommitUnmergedArrow 82syn match gitcommitDiscardedArrow "-> "contained nextgroup = gitcommitDiscardedFile 83syn match gitcommitSelectedArrow "-> "contained nextgroup = gitcommitSelectedFile 84syn match gitcommitUnmergedArrow "-> "contained nextgroup = gitcommitUnmergedFile 85 86hi def link gitcommitSummary Keyword 87hi def link gitcommitTrailerToken Label 88hi def link gitcommitComment Comment 89hi def link gitcommitHash Identifier 90hi def link gitcommitOnBranch Comment 91hi def link gitcommitBranch Special 92hi def link gitcommitNoBranch gitCommitBranch 93hi def link gitcommitDiscardedType gitcommitType 94hi def link gitcommitSelectedType gitcommitType 95hi def link gitcommitUnmergedType gitcommitType 96hi def link gitcommitType Type 97hi def link gitcommitNoChanges gitcommitHeader 98hi def link gitcommitHeader PreProc 99hi def link gitcommitUntrackedFile gitcommitFile 100hi def link gitcommitDiscardedFile gitcommitFile 101hi def link gitcommitSelectedFile gitcommitFile 102hi def link gitcommitUnmergedFile gitcommitFile 103hi def link gitcommitFile Constant 104hi def link gitcommitDiscardedArrow gitcommitArrow 105hi def link gitcommitSelectedArrow gitcommitArrow 106hi def link gitcommitUnmergedArrow gitcommitArrow 107hi def link gitcommitArrow gitcommitComment 108"hi def link gitcommitOverflow Error 109hi def link gitcommitBlank Error 110 111let b: current_syntax = "gitcommit"