├── .github └── FUNDING.yml ├── .gitignore ├── doc └── ft-gitcommit-plugin.txt ├── ftdetect └── git.vim ├── ftplugin ├── git.vim ├── gitcommit.vim ├── gitconfig.vim ├── gitrebase.vim └── gitsendemail.vim ├── indent └── gitconfig.vim └── syntax ├── git.vim ├── gitcommit.vim ├── gitconfig.vim ├── gitrebase.vim └── gitsendemail.vim /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: tpope 2 | custom: ["https://www.paypal.me/vimpope"] 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /doc/tags 2 | -------------------------------------------------------------------------------- /doc/ft-gitcommit-plugin.txt: -------------------------------------------------------------------------------- 1 | GIT COMMIT *ft-gitcommit-plugin* 2 | 3 | One command, :DiffGitCached, is provided to show a diff of the current commit 4 | in the preview window. It is equivalent to calling "git diff --cached" plus 5 | any arguments given to the command. 6 | 7 | GIT REBASE *ft-gitrebase-plugin* 8 | 9 | In a gitrebase filetype buffer, the following commands are provided: 10 | 11 | `:Pick` Changes the cursor line to a `pick` line. 12 | `:Squash` Changes the cursor line to a `squash` line 13 | `:Edit` Changes the cursor line to an `edit` line 14 | `:Reword` Changes the cursor line to a `reword` line 15 | `:Fixup` Changes the cursor line to a `fixup` line 16 | `:Drop` Changes the cursor line to a `drop` line 17 | `:Cycle` Cycles between the first 5 gitrebase commands 18 | 19 | To make the `:Cycle` command more useful, it might be mapped, e.g. > 20 | nnoremap S :Cycle 21 | < 22 | -------------------------------------------------------------------------------- /ftdetect/git.vim: -------------------------------------------------------------------------------- 1 | function! s:Setf(filetype) abort 2 | if &filetype !~# '\<'.a:filetype.'\>' 3 | let &filetype = a:filetype 4 | endif 5 | endfunction 6 | 7 | function! s:StarSetf(ft) abort 8 | if expand("") !~# get(g:, 'ft_ignore_pat', '0\&1') 9 | call s:Setf(a:filetype) 10 | endif 11 | endfunction 12 | 13 | " Git 14 | au BufNewFile,BufRead COMMIT_EDITMSG,TAG_EDITMSG,MERGE_MSG call s:Setf('gitcommit') 15 | au BufNewFile,BufRead NOTES_EDITMSG,EDIT_DESCRIPTION call s:Setf('gitcommit') 16 | au BufNewFile,BufRead *.git/config,.gitconfig,*/etc/gitconfig call s:Setf('gitconfig') 17 | au BufNewFile,BufRead */.config/git/config call s:Setf('gitconfig') 18 | au BufNewFile,BufRead */.git/config.worktree call s:Setf('gitconfig') 19 | au BufNewFile,BufRead */.git/worktrees/*/config.worktree call s:Setf('gitconfig') 20 | au BufNewFile,BufRead .gitmodules,*.git/modules/*/config call s:Setf('gitconfig') 21 | if !empty($XDG_CONFIG_HOME) 22 | au BufNewFile,BufRead $XDG_CONFIG_HOME/git/config call s:Setf('gitconfig') 23 | endif 24 | au BufNewFile,BufRead git-rebase-todo call s:Setf('gitrebase') 25 | au BufNewFile,BufRead .gitsendemail.msg.?????? call s:Setf('gitsendemail') 26 | au BufNewFile,BufRead *.git/* 27 | \ if empty(&filetype) && getline(1) =~# '^\x\{40,\}\>\|^ref: ' | 28 | \ set ft=git | 29 | \ endif 30 | 31 | au BufNewFile,BufRead */.gitconfig.d/*,/etc/gitconfig.d/* call s:StarSetf('gitconfig') 32 | 33 | au BufNewFile,BufRead *.patch 34 | \ if getline(1) =~# '^From [0-9a-f]\{40,\} Mon Sep 17 00:00:00 2001$' | 35 | \ call s:Setf('gitsendemail') | 36 | \ endif 37 | 38 | " This logic really belongs in scripts.vim 39 | au BufNewFile,BufRead,StdinReadPost * 40 | \ if empty(&filetype) && getline(1) =~# '^\(commit\|tree\|object\) \x\{40,\}\>\|^tag \S\+$' | 41 | \ set ft=git | 42 | \ endif 43 | -------------------------------------------------------------------------------- /ftplugin/git.vim: -------------------------------------------------------------------------------- 1 | " Vim filetype plugin 2 | " Language: generic git output 3 | " Maintainer: Tim Pope 4 | " Last Change: 2023 Mar 26 5 | 6 | " Only do this when not done yet for this buffer 7 | if (exists("b:did_ftplugin")) 8 | finish 9 | endif 10 | 11 | let b:did_ftplugin = 1 12 | 13 | setlocal nomodeline 14 | 15 | let b:undo_ftplugin = "setl modeline<" 16 | -------------------------------------------------------------------------------- /ftplugin/gitcommit.vim: -------------------------------------------------------------------------------- 1 | " Vim filetype plugin 2 | " Language: git commit file 3 | " Maintainer: Tim Pope 4 | " Last Change: 2022 Jan 05 5 | 6 | " Only do this when not done yet for this buffer 7 | if (exists("b:did_ftplugin")) 8 | finish 9 | endif 10 | 11 | let b:did_ftplugin = 1 12 | 13 | setlocal nomodeline tabstop=8 formatoptions+=tl textwidth=72 14 | setlocal formatoptions-=c formatoptions-=r formatoptions-=o formatoptions-=q formatoptions+=n 15 | setlocal formatlistpat=^\\s*\\d\\+[\\]:.)}]\\s\\+\\\|^\\s*[-*+]\\s\\+ 16 | setlocal include=^+++ 17 | setlocal includeexpr=substitute(v:fname,'^[bi]/','','') 18 | 19 | let b:undo_ftplugin = 'setl modeline< tabstop< formatoptions< tw< com< cms< formatlistpat< inc< inex<' 20 | 21 | let s:l = search('\C\m^[#;@!$%^&|:] -\{24,\} >8 -\{24,\}$', 'cnW', '', 100) 22 | let &l:comments = ':' . (matchstr(getline(s:l ? s:l : '$'), '^[#;@!$%^&|:]\S\@!') . '#')[0] 23 | let &l:commentstring = &l:comments[1] . ' %s' 24 | unlet s:l 25 | 26 | if exists("g:no_gitcommit_commands") 27 | finish 28 | endif 29 | 30 | command! -bang -bar -buffer -complete=custom,s:diffcomplete -nargs=* DiffGitCached :call s:gitdiffcached(0, ) 31 | 32 | let b:undo_ftplugin = b:undo_ftplugin . "|delc DiffGitCached" 33 | 34 | function! s:diffcomplete(A, L, P) abort 35 | let args = "" 36 | if a:P <= match(a:L." -- "," -- ")+3 37 | let args = args . "-p\n--stat\n--shortstat\n--summary\n--patch-with-stat\n--no-renames\n-B\n-M\n-C\n" 38 | end 39 | if a:A !~ '^-' && !empty(getftype('.git')) 40 | let args = args."\n".system("git diff --cached --name-only") 41 | endif 42 | return args 43 | endfunction 44 | 45 | function! s:setupdiff() abort 46 | command! -bang -bar -buffer -complete=custom,s:diffcomplete -nargs=* DiffGitCached :call s:gitdiffcached(0, ) 47 | setlocal buftype=nowrite nobuflisted noswapfile nomodifiable filetype=git 48 | endfunction 49 | 50 | function! s:gitdiffcached(bang, ...) abort 51 | let name = tempname() 52 | if a:0 53 | let extra = join(map(copy(a:000), 'shellescape(v:val)')) 54 | else 55 | let extra = "-p --stat=".&columns 56 | endif 57 | call system("git diff --cached --no-color --no-ext-diff ".extra." > ".shellescape(name)) 58 | exe 'pedit +call\ s:setupdiff()' fnameescape(name) 59 | silent! wincmd P 60 | endfunction 61 | -------------------------------------------------------------------------------- /ftplugin/gitconfig.vim: -------------------------------------------------------------------------------- 1 | " Vim filetype plugin 2 | " Language: git config file 3 | " Maintainer: Tim Pope 4 | " Last Change: 2009 Dec 24 5 | 6 | " Only do this when not done yet for this buffer 7 | if (exists("b:did_ftplugin")) 8 | finish 9 | endif 10 | let b:did_ftplugin = 1 11 | 12 | setlocal formatoptions-=t formatoptions+=croql 13 | setlocal comments=:#,:; commentstring=;\ %s 14 | 15 | let b:undo_ftplugin = "setl fo< com< cms<" 16 | -------------------------------------------------------------------------------- /ftplugin/gitrebase.vim: -------------------------------------------------------------------------------- 1 | " Vim filetype plugin 2 | " Language: git rebase --interactive 3 | " Maintainer: Tim Pope 4 | " Last Change: 2022 Jan 05 5 | 6 | " Only do this when not done yet for this buffer 7 | if (exists("b:did_ftplugin")) 8 | finish 9 | endif 10 | 11 | let b:did_ftplugin = 1 12 | 13 | let &l:comments = ':' . (matchstr(getline('$'), '^[#;@!$%^&|:]\S\@!') . '#')[0] 14 | let &l:commentstring = &l:comments[1] . ' %s' 15 | setlocal formatoptions-=t 16 | setlocal nomodeline 17 | let b:undo_ftplugin = "setl com< cms< fo< ml<" 18 | 19 | function! s:choose(word) abort 20 | s/^\(\w\+\>\)\=\(\s*\)\ze\x\{4,\}\>/\=(strlen(submatch(1)) == 1 ? a:word[0] : a:word) . substitute(submatch(2),'^$',' ','')/e 21 | endfunction 22 | 23 | function! s:cycle(count) abort 24 | let words = ['pick', 'edit', 'fixup', 'squash', 'reword', 'drop'] 25 | let index = index(map(copy(words), 'v:val[0]'), getline('.')[0]) 26 | let index = ((index < 0 ? 0 : index) + 10000 * len(words) + a:count) % len(words) 27 | call s:choose(words[index]) 28 | endfunction 29 | 30 | command! -buffer -bar -range Pick :,call s:choose('pick') 31 | command! -buffer -bar -range Squash :,call s:choose('squash') 32 | command! -buffer -bar -range Edit :,call s:choose('edit') 33 | command! -buffer -bar -range Reword :,call s:choose('reword') 34 | command! -buffer -bar -range Fixup :,call s:choose('fixup') 35 | command! -buffer -bar -range Drop :,call s:choose('drop') 36 | command! -buffer -count=1 -bar -bang Cycle call s:cycle(0 ? - : ) 37 | 38 | if exists("g:no_plugin_maps") || exists("g:no_gitrebase_maps") 39 | finish 40 | endif 41 | 42 | nnoremap :=v:count1Cycle 43 | nnoremap :=v:count1Cycle! 44 | 45 | let b:undo_ftplugin = b:undo_ftplugin . "|exe 'nunmap '|exe 'nunmap '" 46 | -------------------------------------------------------------------------------- /ftplugin/gitsendemail.vim: -------------------------------------------------------------------------------- 1 | " Vim filetype plugin 2 | " Language: git send-email message 3 | " Maintainer: Tim Pope 4 | " Last Change: 2009 Dec 24 5 | 6 | runtime! ftplugin/mail.vim 7 | -------------------------------------------------------------------------------- /indent/gitconfig.vim: -------------------------------------------------------------------------------- 1 | " Vim indent file 2 | " Language: git config file 3 | " Maintainer: Tim Pope 4 | " Last Change: 2017 Jun 13 5 | 6 | if exists("b:did_indent") 7 | finish 8 | endif 9 | let b:did_indent = 1 10 | 11 | setlocal autoindent 12 | setlocal indentexpr=GetGitconfigIndent() 13 | setlocal indentkeys=o,O,*,0[,],0;,0#,=,!^F 14 | 15 | let b:undo_indent = 'setl ai< inde< indk<' 16 | 17 | " Only define the function once. 18 | if exists("*GetGitconfigIndent") 19 | finish 20 | endif 21 | 22 | function! GetGitconfigIndent() 23 | let sw = shiftwidth() 24 | let line = getline(prevnonblank(v:lnum-1)) 25 | let cline = getline(v:lnum) 26 | if line =~ '\\\@ 4 | " Last Change: 2022 Jan 05 5 | 6 | if exists("b:current_syntax") 7 | finish 8 | endif 9 | 10 | syn case match 11 | syn sync minlines=50 12 | 13 | syn include @gitDiff syntax/diff.vim 14 | 15 | syn region gitHead start=/\%^\%(tag \|tree \|object \)\@=/ end=/^$/ contains=@NoSpell 16 | syn region gitHead start=/\%(^commit\%( \x\{4,\}\)\{1,\}\%(\s*(.*)\)\=$\)\@=/ end=/^$/ contains=@NoSpell 17 | " git log --oneline 18 | " minimize false positives by verifying contents of buffer 19 | if getline(1) =~# '^\x\{7,\} ' && getline('$') =~# '^\x\{7,\} ' 20 | syn match gitHashAbbrev /^\x\{7,\} \@=/ contains=@NoSpell 21 | elseif getline(1) =~# '^[|\/\\_ ]\{-\}\*[|\/\\_ ]\{-\} \x\{7,\} ' 22 | syn match gitHashAbbrev /^[|\/\\_ ]\{-\}\*[|\/\\_ ]\{-\} \zs\x\{7,\} \@=/ contains=@NoSpell 23 | endif 24 | " git log --graph 25 | syn region gitGraph start=/\%(^[|\/\\_ ]*\*[|\/\\_ ]\{-\} commit\%( \x\{4,\}\)\{1,\}\%(\s*(.*)\)\=$\)\@=/ end=/^\%([|\/\\_ ]*$\)\@=/ contains=@NoSpell 26 | " git blame --porcelain 27 | syn region gitHead start=/\%(^\x\{40,\} \d\+ \d\+\%( \d\+\)\=$\)\@=/ end=/^\t\@=/ contains=@NoSpell 28 | " git ls-tree 29 | syn match gitMode /^\d\{6\}\%( \%(blob\|tree\) \x\{4,\}\t\)\@=/ nextgroup=gitType skipwhite contains=@NoSpell 30 | " git ls-files --stage 31 | syn match gitMode /^\d\{6\}\%( \x\{4,\} [0-3]\t\)\@=/ nextgroup=gitHashStage skipwhite contains=@NoSpell 32 | " .git/HEAD, .git/refs/ 33 | syn match gitKeyword /\%^ref: \@=/ nextgroup=gitReference skipwhite contains=@NoSpell 34 | syn match gitHash /\%^\x\{40,}\%$/ skipwhite contains=@NoSpell 35 | " .git/logs/ 36 | syn match gitReflog /^\x\{40,\} \x\{40,\} .\{-\}\d\+\s-\d\{4\}\t.*/ skipwhite contains=@NoSpell,gitReflogOld 37 | 38 | syn region gitDiff start=/^\%(diff --git \)\@=/ end=/^\%(diff --\|$\)\@=/ contains=@gitDiff fold 39 | syn region gitDiff start=/^\%(@@ -\)\@=/ end=/^\%(diff --\%(git\|cc\|combined\) \|$\)\@=/ contains=@gitDiff 40 | 41 | syn region gitDiffMerge start=/^\%(diff --\%(cc\|combined\) \)\@=/ end=/^\%(diff --\|$\)\@=/ contains=@gitDiff fold 42 | syn region gitDiffMerge start=/^\%(@@@@* -\)\@=/ end=/^\%(diff --\|$\)\@=/ contains=@gitDiff 43 | syn match gitDiffAdded "^ \++.*" contained containedin=gitDiffMerge 44 | syn match gitDiffAdded "{+[^}]*+}" contained containedin=gitDiff 45 | syn match gitDiffRemoved "^ \+-.*" contained containedin=gitDiffMerge 46 | syn match gitDiffRemoved "\[-[^]]*-\]" contained containedin=gitDiff 47 | 48 | syn match gitKeyword /^commit \@=/ contained containedin=gitHead nextgroup=gitHashAbbrev skipwhite contains=@NoSpell 49 | syn match gitKeyword /^\%(object\|tree\|parent\|encoding\|gpgsig\%(-\w\+\)\=\|previous\) \@=/ contained containedin=gitHead nextgroup=gitHash skipwhite contains=@NoSpell 50 | syn match gitKeyword /^Merge:/ contained containedin=gitHead nextgroup=gitHashAbbrev skipwhite contains=@NoSpell 51 | syn match gitIdentityKeyword /^\%(author\|committer\|tagger\) \@=/ contained containedin=gitHead nextgroup=gitIdentity skipwhite contains=@NoSpell 52 | syn match gitIdentityHeader /^\%(Author\|Commit\|Tagger\):/ contained containedin=gitHead nextgroup=gitIdentity skipwhite contains=@NoSpell 53 | syn match gitDateHeader /^\%(AuthorDate\|CommitDate\|Date\):/ contained containedin=gitHead nextgroup=gitDate skipwhite contains=@NoSpell 54 | 55 | syn match gitKeyword /^[*|\/\\_ ]\+\zscommit \@=/ contained containedin=gitGraph nextgroup=gitHashAbbrev skipwhite contains=@NoSpell 56 | syn match gitKeyword /^[|\/\\_ ]\+\zs\%(object\|tree\|parent\|encoding\|gpgsig\%(-\w\+\)\=\|previous\) \@=/ contained containedin=gitGraph nextgroup=gitHash skipwhite contains=@NoSpell 57 | syn match gitKeyword /^[|\/\\_ ]\+\zsMerge:/ contained containedin=gitGraph nextgroup=gitHashAbbrev skipwhite contains=@NoSpell 58 | syn match gitIdentityKeyword /^[|\/\\_ ]\+\zs\%(author\|committer\|tagger\) \@=/ contained containedin=gitGraph nextgroup=gitIdentity skipwhite contains=@NoSpell 59 | syn match gitIdentityHeader /^[|\/\\_ ]\+\zs\%(Author\|Commit\|Tagger\):/ contained containedin=gitGraph nextgroup=gitIdentity skipwhite contains=@NoSpell 60 | syn match gitDateHeader /^[|\/\\_ ]\+\zs\%(AuthorDate\|CommitDate\|Date\):/ contained containedin=gitGraph nextgroup=gitDate skipwhite contains=@NoSpell 61 | 62 | syn match gitKeyword /^type \@=/ contained containedin=gitHead nextgroup=gitType skipwhite contains=@NoSpell 63 | syn match gitKeyword /^\%(summary\|boundary\|filename\|\%(author\|committer\)-\%(time\|tz\)\) \@=/ contained containedin=gitHead skipwhite contains=@NoSpell 64 | syn match gitKeyword /^tag \@=/ contained containedin=gitHead nextgroup=gitReference skipwhite contains=@NoSpell 65 | syn match gitIdentityKeyword /^\%(author\|committer\)-mail \@=/ contained containedin=gitHead nextgroup=gitEmail skipwhite contains=@NoSpell 66 | syn match gitReflogHeader /^Reflog:/ contained containedin=gitHead nextgroup=gitReflogMiddle skipwhite contains=@NoSpell 67 | syn match gitReflogHeader /^Reflog message:/ contained containedin=gitHead skipwhite contains=@NoSpell 68 | syn match gitReflogMiddle /\S\+@{\d\+} (/he=e-2 nextgroup=gitIdentity contains=@NoSpell 69 | 70 | syn match gitIdentity /\S.\{-\} <[^>]*>/ contained nextgroup=gitDate skipwhite contains=@NoSpell 71 | syn region gitEmail matchgroup=gitEmailDelimiter start=// keepend oneline contained containedin=gitIdentity contains=@NoSpell 72 | syn match gitDate /\<\u\l\l \u\l\l \d\=\d \d\d:\d\d:\d\d \d\d\d\d [+-]\d\d\d\d/ contained contains=@NoSpell 73 | syn match gitDate /-\=\d\+ [+-]\d\d\d\d\>/ contained contains=@NoSpell 74 | syn match gitDate /\<\d\+ \l\+ ago\>/ contained contains=@NoSpell 75 | syn match gitType /\<\%(tag\|commit\|tree\|blob\)\>/ contained nextgroup=gitHashAbbrev skipwhite contains=@NoSpell 76 | syn match gitReference /\S\+\S\@!/ contained contains=@NoSpell 77 | syn match gitHash /\<\x\{40,\}\>/ contained nextgroup=gitIdentity,gitHash skipwhite contains=@NoSpell 78 | syn match gitReflogOld /^\x\{40,\} \@=/ contained nextgroup=gitReflogNew skipwhite contains=@NoSpell 79 | syn match gitReflogNew /\<\x\{40,\} \@=/ contained nextgroup=gitIdentity skipwhite contains=@NoSpell 80 | syn match gitHashAbbrev /\<\x\{4,\}\>/ contained nextgroup=gitHashAbbrev skipwhite contains=@NoSpell 81 | syn match gitHashAbbrev /\<\x\{4,39\}\.\.\./he=e-3 contained nextgroup=gitHashAbbrev skipwhite contains=@NoSpell 82 | syn match gitHashStage /\<\x\{4,\}\>/ contained nextgroup=gitStage skipwhite contains=@NoSpell 83 | syn match gitStage /\<\d\t\@=/ contained contains=@NoSpell 84 | 85 | 86 | syn match gitNotesHeader /^Notes:\ze\n / 87 | 88 | hi def link gitDateHeader gitIdentityHeader 89 | hi def link gitIdentityHeader gitIdentityKeyword 90 | hi def link gitIdentityKeyword Label 91 | hi def link gitNotesHeader gitKeyword 92 | hi def link gitReflogHeader gitKeyword 93 | hi def link gitKeyword Keyword 94 | hi def link gitIdentity String 95 | hi def link gitEmailDelimiter Delimiter 96 | hi def link gitEmail Special 97 | hi def link gitDate Number 98 | hi def link gitMode Number 99 | hi def link gitHashStage gitHash 100 | hi def link gitHashAbbrev gitHash 101 | hi def link gitReflogOld gitHash 102 | hi def link gitReflogNew gitHash 103 | hi def link gitHash Identifier 104 | hi def link gitReflogMiddle gitReference 105 | hi def link gitReference Function 106 | hi def link gitStage gitType 107 | hi def link gitType Type 108 | hi def link gitDiffAdded diffAdded 109 | hi def link gitDiffRemoved diffRemoved 110 | 111 | let b:current_syntax = "git" 112 | -------------------------------------------------------------------------------- /syntax/gitcommit.vim: -------------------------------------------------------------------------------- 1 | " Vim syntax file 2 | " Language: git commit file 3 | " Maintainer: Tim Pope 4 | " Filenames: *.git/COMMIT_EDITMSG 5 | " Last Change: 2022 Jan 05 6 | 7 | if exists("b:current_syntax") 8 | finish 9 | endif 10 | 11 | scriptencoding utf-8 12 | 13 | syn case match 14 | syn sync minlines=50 15 | syn sync linebreaks=1 16 | 17 | if has("spell") 18 | syn spell toplevel 19 | endif 20 | 21 | syn include @gitcommitDiff syntax/diff.vim 22 | syn region gitcommitDiff start=/\%(^diff --\%(git\|cc\|combined\) \)\@=/ end=/^\%(diff --\|$\|@@\@!\|[^[:alnum:]\ +-]\S\@!\)\@=/ fold contains=@gitcommitDiff 23 | 24 | if get(g:, 'gitcommit_summary_length') < 0 25 | syn match gitcommitSummary "^.*$" contained containedin=gitcommitFirstLine nextgroup=gitcommitOverflow contains=@Spell 26 | elseif get(g:, 'gitcommit_summary_length', 1) > 0 27 | exe 'syn match gitcommitSummary "^.*\%<' . (get(g:, 'gitcommit_summary_length', 50) + 1) . 'v." contained containedin=gitcommitFirstLine nextgroup=gitcommitOverflow contains=@Spell' 28 | endif 29 | syn match gitcommitOverflow ".*" contained contains=@Spell 30 | syn match gitcommitBlank "^.\+" contained contains=@Spell 31 | syn match gitcommitFirstLine "\%^.*" nextgroup=gitcommitBlank,gitcommitComment skipnl 32 | 33 | let s:scissors = 0 34 | let s:l = search('^[#;@!$%^&|:] -\{24,\} >8 -\{24,\}$', 'cnW', '', 100) 35 | if s:l == 0 36 | let s:l = line('$') 37 | elseif getline(s:l)[0] !=# getline(s:l - 1)[0] 38 | let s:scissors = 1 39 | endif 40 | let s:comment = escape((matchstr(getline(s:l), '^[#;@!$%^&|:]\S\@!') . '#')[0], '^$.*[]~\"/') 41 | 42 | if s:scissors 43 | let s:comment .= ' -\{24,\} >8 -\{24,\}$' 44 | exe 'syn region gitcommitComment start="^' . s:comment . '" end="\%$" contains=gitcommitDiff' 45 | else 46 | exe 'syn match gitcommitComment "^' . s:comment . '.*"' 47 | endif 48 | exe '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 | 50 | unlet s:l s:comment s:scissors 51 | 52 | syn match gitcommitTrailerToken "^[[:alnum:]-]\+\s*:" contained containedin=gitcommitTrailers 53 | 54 | syn match gitcommitHash "\<\x\{40}\>\|\<\x\{64}\>" contains=@NoSpell display 55 | syn match gitcommitOnBranch "\%(^. \)\@<=On branch" contained containedin=gitcommitComment nextgroup=gitcommitBranch skipwhite 56 | syn match gitcommitOnBranch "\%(^. \)\@<=Your branch .\{-\} '" contained containedin=gitcommitComment nextgroup=gitcommitBranch skipwhite 57 | syn match gitcommitBranch "[^ ']\+" contained 58 | syn match gitcommitNoBranch "\%(^. \)\@<=Not currently on any branch." contained containedin=gitcommitComment 59 | syn match gitcommitHeader "\%(^. \)\@<=\S.*[::]\%(\n^$\)\@!$" contained containedin=gitcommitComment 60 | syn region gitcommitAuthor matchgroup=gitCommitHeader start=/\%(^. \)\@<=\%(Author\|Committer\|Date\):/ end=/$/ keepend oneline contained containedin=gitcommitComment transparent 61 | syn match gitcommitHeader "\%(^. \)\@<=commit\%( \x\{40,\}$\)\@=" contained containedin=gitcommitComment nextgroup=gitcommitHash skipwhite 62 | syn match gitcommitNoChanges "\%(^. \)\@<=No changes$" contained containedin=gitcommitComment 63 | 64 | syn match gitcommitType "\%(^.\t\)\@<=[^[:punct:][:space:]][^/::]*[^[:punct:][:space:]][::]\ze "he=e-1 contained containedin=gitcommitComment nextgroup=gitcommitFile skipwhite 65 | syn match gitcommitFile ".\{-\}\%($\| -> \)\@=" contained nextgroup=gitcommitArrow 66 | syn match gitcommitArrow " -> " contained nextgroup=gitcommitFile 67 | syn match gitcommitUntrackedFile "\%(^.\t\)\@<=[^::/]*\%(/.*\)\=$" contained containedin=gitcommitComment 68 | 69 | syn region gitcommitUntracked start=/^\z(.\) Untracked files:$/ end=/^\z1\=$\|^\z1\@!/ contains=gitcommitHeader containedin=gitcommitComment containedin=gitcommitComment contained transparent fold 70 | syn 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 71 | syn region gitcommitSelected start=/^\z(.\) Changes to be committed:$/ end=/^\z1$\|^\z1\@!/ contains=gitcommitHeader,gitcommitSelectedType containedin=gitcommitComment containedin=gitcommitComment contained transparent fold 72 | syn region gitcommitUnmerged start=/^\z(.\) Unmerged paths:$/ end=/^\z1\=$\|^\z1\@!/ contains=gitcommitHeader,gitcommitUnmergedType containedin=gitcommitComment containedin=gitcommitComment contained transparent fold 73 | 74 | syn match gitcommitUntrackedFile "\%(^.\t\)\@<=.*" contained containedin=gitcommitUntracked 75 | 76 | syn match gitcommitDiscardedType "\%(^.\t\)\@<=[^[:punct:][:space:]][^/::]*[^[:punct:][:space:]][::]\ze "he=e-1 contained nextgroup=gitcommitDiscardedFile skipwhite 77 | syn match gitcommitSelectedType "\%(^.\t\)\@<=[^[:punct:][:space:]][^/::]*[^[:punct:][:space:]][::]\ze "he=e-1 contained nextgroup=gitcommitSelectedFile skipwhite 78 | syn match gitcommitUnmergedType "\%(^.\t\)\@<=[^[:punct:][:space:]][^/::]*[^[:punct:][:space:]][::]\ze "he=e-1 contained nextgroup=gitcommitUnmergedFile skipwhite 79 | syn match gitcommitDiscardedFile "\S.\{-\}\%($\| -> \)\@=" contained nextgroup=gitcommitDiscardedArrow 80 | syn match gitcommitSelectedFile "\S.\{-\}\%($\| -> \)\@=" contained nextgroup=gitcommitSelectedArrow 81 | syn match gitcommitUnmergedFile "\S.\{-\}\%($\| -> \)\@=" contained nextgroup=gitcommitUnmergedArrow 82 | syn match gitcommitDiscardedArrow " -> " contained nextgroup=gitcommitDiscardedFile 83 | syn match gitcommitSelectedArrow " -> " contained nextgroup=gitcommitSelectedFile 84 | syn match gitcommitUnmergedArrow " -> " contained nextgroup=gitcommitUnmergedFile 85 | 86 | hi def link gitcommitSummary Keyword 87 | hi def link gitcommitTrailerToken Label 88 | hi def link gitcommitComment Comment 89 | hi def link gitcommitHash Identifier 90 | hi def link gitcommitOnBranch Comment 91 | hi def link gitcommitBranch Special 92 | hi def link gitcommitNoBranch gitCommitBranch 93 | hi def link gitcommitDiscardedType gitcommitType 94 | hi def link gitcommitSelectedType gitcommitType 95 | hi def link gitcommitUnmergedType gitcommitType 96 | hi def link gitcommitType Type 97 | hi def link gitcommitNoChanges gitcommitHeader 98 | hi def link gitcommitHeader PreProc 99 | hi def link gitcommitUntrackedFile gitcommitFile 100 | hi def link gitcommitDiscardedFile gitcommitFile 101 | hi def link gitcommitSelectedFile gitcommitFile 102 | hi def link gitcommitUnmergedFile gitcommitFile 103 | hi def link gitcommitFile Constant 104 | hi def link gitcommitDiscardedArrow gitcommitArrow 105 | hi def link gitcommitSelectedArrow gitcommitArrow 106 | hi def link gitcommitUnmergedArrow gitcommitArrow 107 | hi def link gitcommitArrow gitcommitComment 108 | "hi def link gitcommitOverflow Error 109 | hi def link gitcommitBlank Error 110 | 111 | let b:current_syntax = "gitcommit" 112 | -------------------------------------------------------------------------------- /syntax/gitconfig.vim: -------------------------------------------------------------------------------- 1 | " Vim syntax file 2 | " Language: git config file 3 | " Maintainer: Tim Pope 4 | " Filenames: gitconfig, .gitconfig, *.git/config 5 | " Last Change: 2019 Dec 05 6 | 7 | if exists("b:current_syntax") 8 | finish 9 | endif 10 | 11 | syn case ignore 12 | syn sync minlines=10 13 | 14 | syn match gitconfigComment "[#;].*" contains=@Spell 15 | syn match gitconfigSection "\%(^\s*\)\@<=\[[a-z0-9.-]\+\]" 16 | syn match gitconfigSection '\%(^\s*\)\@<=\[[a-z0-9.-]\+ \+\"\%([^\\"]\|\\.\)*"\]' 17 | syn match gitconfigVariable "\%(^\s*\)\@<=\a[a-z0-9-]*\%(\s*\%([=#;]\|$\)\)\@=" nextgroup=gitconfigAssignment skipwhite 18 | syn region gitconfigAssignment matchgroup=gitconfigNone start=+=\s*+ skip=+\\+ end=+\s*$+ contained contains=gitconfigBoolean,gitconfigNumber,gitConfigString,gitConfigEscape,gitConfigError,gitconfigComment keepend 19 | syn keyword gitconfigBoolean true false yes no contained 20 | syn match gitconfigNumber "\<\d\+\>" contained 21 | syn region gitconfigString matchgroup=gitconfigDelim start=+"+ skip=+\\+ end=+"+ matchgroup=gitconfigError end=+[^\\"]\%#\@!$+ contained contains=gitconfigEscape,gitconfigEscapeError 22 | syn match gitconfigError +\\.+ contained 23 | syn match gitconfigEscape +\\[\\"ntb]+ contained 24 | syn match gitconfigEscape +\\$+ contained 25 | 26 | hi def link gitconfigComment Comment 27 | hi def link gitconfigSection Keyword 28 | hi def link gitconfigVariable Identifier 29 | hi def link gitconfigBoolean Boolean 30 | hi def link gitconfigNumber Number 31 | hi def link gitconfigString String 32 | hi def link gitconfigDelim Delimiter 33 | hi def link gitconfigEscape Special 34 | hi def link gitconfigError Error 35 | 36 | let b:current_syntax = "gitconfig" 37 | -------------------------------------------------------------------------------- /syntax/gitrebase.vim: -------------------------------------------------------------------------------- 1 | " Vim syntax file 2 | " Language: git rebase --interactive 3 | " Maintainer: Tim Pope 4 | " Filenames: git-rebase-todo 5 | " Last Change: 2022 Jan 05 6 | 7 | if exists("b:current_syntax") 8 | finish 9 | endif 10 | 11 | syn case match 12 | 13 | let s:c = escape((matchstr(getline('$'), '^[#;@!$%^&|:]\S\@!') . '#')[0], '^$.*[]~\"/') 14 | 15 | syn match gitrebaseHash "\v<\x{7,}>" contained contains=@NoSpell 16 | syn match gitrebaseCommit "\v<\x{7,}>" nextgroup=gitrebaseSummary skipwhite contains=@NoSpell 17 | syn match gitrebasePick "\v^p%(ick)=>" nextgroup=gitrebaseCommit skipwhite 18 | syn match gitrebaseReword "\v^r%(eword)=>" nextgroup=gitrebaseCommit skipwhite 19 | syn match gitrebaseEdit "\v^e%(dit)=>" nextgroup=gitrebaseCommit skipwhite 20 | syn match gitrebaseSquash "\v^s%(quash)=>" nextgroup=gitrebaseCommit skipwhite 21 | syn match gitrebaseFixup "\v^f%(ixup)=>" nextgroup=gitrebaseCommit skipwhite 22 | syn match gitrebaseExec "\v^%(x|exec)>" nextgroup=gitrebaseCommand skipwhite 23 | syn match gitrebaseBreak "\v^b%(reak)=>" 24 | syn match gitrebaseDrop "\v^d%(rop)=>" nextgroup=gitrebaseCommit skipwhite 25 | syn match gitrebaseNoop "\v^noop>" 26 | syn match gitrebaseMerge "\v^m(erge)=>" nextgroup=gitrebaseMergeOption,gitrebaseName skipwhite 27 | syn match gitrebaseLabel "\v^l(abel)=>" nextgroup=gitrebaseName skipwhite 28 | syn match gitrebaseReset "\v^(t|reset)=>" nextgroup=gitrebaseName skipwhite 29 | syn match gitrebaseUpdateRef "\v^u%(pdate-ref)=>" nextgroup=gitrebaseRefHead skipwhite 30 | syn match gitrebaseSummary ".*" contains=gitrebaseHash contained 31 | syn match gitrebaseCommand ".*" contained 32 | exe 'syn match gitrebaseComment " \@<=' . s:c . ' empty$" containedin=gitrebaseSummary contained' 33 | exe 'syn match gitrebaseComment "^\s*' . s:c . '.*" contains=gitrebaseHash' 34 | syn match gitrebaseSquashError "\v%^%(s%(quash)=>|f%(ixup)=>)" nextgroup=gitrebaseCommit skipwhite 35 | syn match gitrebaseMergeOption "\v-[Cc]>" nextgroup=gitrebaseMergeCommit skipwhite contained 36 | syn match gitrebaseMergeCommit "\v<\x{7,}>" nextgroup=gitrebaseName skipwhite contained 37 | syn match gitrebaseName "\v[^[:space:].*?i:^~/-]\S+" nextgroup=gitrebaseMergeComment skipwhite contained 38 | syn match gitrebaseRefHead "\