robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
419f038727
master
1" Vim filetype plugin 2" Language: git commit file 3" Maintainer: Tim Pope <vimNOSPAM@tpope.org> 4" Last Change: 2023 Dec 28 5 6" Only do this when not done yet for this buffer 7if ( exists ( "b:did_ftplugin" )) 8finish 9endif 10 11let b: did_ftplugin = 1 12 13setlocal nomodeline tabstop = 8 formatoptions += tltextwidth = 72 14setlocal formatoptions -= cformatoptions -= rformatoptions -= oformatoptions -= qformatoptions += n 15setlocal formatlistpat = ^\\s*\\d\\+[\\]:.)}]\\s\\+\\\|^\\s*[-*+]\\s\\+ 16setlocal include = ^+++ 17setlocal includeexpr = substitute (v:fname,'^ [ bi ] /','','') 18 19let b: undo_ftplugin = 'setl modeline< tabstop< formatoptions< tw< com< cms< formatlistpat< inc< inex<' 20 21let s: l = search ( '\C\m^[#;@!$%^&|:] -\{24,\} >8 -\{24,\}$' , 'cnW' , '' , 100 ) 22let & l: comments = ':' . ( matchstr ( getline ( s: l ? s: l : '$' ), '^[#;@!$%^&|:]\S\@!' ) . '#' )[ 0 ] 23let & l: commentstring = & l: comments [ 1 ] . ' %s' 24unlet s: l 25 26if exists ( "g:no_gitcommit_commands" ) 27finish 28endif 29 30command ! -bang -bar -buffer -complete = custom , s: diffcomplete -nargs = * DiffGitCached :call s:gitdiffcached(<bang>0, <f-args>) 31 32let b: undo_ftplugin = b: undo_ftplugin . "|delc DiffGitCached" 33 34function ! s: diffcomplete ( A , L , P ) abort 35let args = "" 36if a: P <= match ( a: L . " -- " , " -- " ) + 3 37let args = args . "-p\n--stat\n--shortstat\n--summary\n--patch-with-stat\n--no-renames\n-B\n-M\n-C\n" 38end 39if a: A !~ '^-' && ! empty ( getftype ( '.git' )) 40let args = args . "\n" . system ( "git diff --cached --name-only" ) 41endif 42return args 43endfunction 44 45function ! s: setupdiff () abort 46command ! -bang -bar -buffer -complete = custom , s: diffcomplete -nargs = * DiffGitCached :call s:gitdiffcached(<bang>0, <f-args>) 47setlocal buftype = nowritenobuflisted noswapfile nomodifiable filetype = git 48endfunction 49 50function ! s: gitdiffcached ( bang , ...) abort 51let name = tempname () 52if a: 0 53let extra = join ( map ( copy ( a: 000 ), 'shellescape(v:val)' )) 54else 55let extra = "-p --stat=" .& columns 56endif 57call system ( "git diff --cached --no-color --no-ext-diff " . extra . " > " . shellescape ( name )) 58exe 'pedit +call\ s:setupdiff()' fnameescape ( name ) 59silent ! wincmd P 60endfunction