11" Vim filetype plugin
22" Language: git commit file
33" Maintainer: Tim Pope <[email protected] >4- " Last Change: 2022 Jan 05
4+ " Last Change: 2023 Dec 28
55
66" Only do this when not done yet for this buffer
77if (exists (" b:did_ftplugin" ))
@@ -12,7 +12,7 @@ let b:did_ftplugin = 1
1212
1313setlocal nomodeline tabstop = 8 formatoptions += tl textwidth = 72
1414setlocal formatoptions -= c formatoptions -= r formatoptions -= o formatoptions -= q formatoptions += n
15- setlocal formatlistpat += \\ \| ^\\ s * [-*+ ]\\ s \\ +
15+ setlocal formatlistpat = ^ \\ s * \\ d \\ + [ \\ ]:.)}] \\ s \\ + \\ \| ^\\ s * [-*+ ]\\ s \\ +
1616setlocal include = ^+++
1717setlocal includeexpr = substitute (v: fname ,' ^[bi]/' ,' ' ,' ' )
1818
@@ -42,6 +42,11 @@ function! s:diffcomplete(A, L, P) abort
4242 return args
4343endfunction
4444
45+ function ! s: setupdiff () abort
46+ command ! - bang - bar - buffer -complete =custom ,s: diffcomplete -nargs =* DiffGitCached :call s: gitdiffcached (<bang> 0 , <f-args> )
47+ setlocal buftype = nowrite nobuflisted noswapfile nomodifiable filetype = git
48+ endfunction
49+
4550function ! s: gitdiffcached (bang , ... ) abort
4651 let name = tempname ()
4752 if a: 0
@@ -50,8 +55,6 @@ function! s:gitdiffcached(bang, ...) abort
5055 let extra = " -p --stat=" .&columns
5156 endif
5257 call system (" git diff --cached --no-color --no-ext-diff " .extra." > " .shellescape (name))
53- exe " pedit " . fnameescape (name)
54- wincmd P
55- command ! - bang - bar - buffer -complete =custom ,s: diffcomplete -nargs =* DiffGitCached :call s: gitdiffcached (<bang> 0 , <f-args> )
56- setlocal buftype = nowrite nobuflisted noswapfile nomodifiable filetype = git
58+ exe ' pedit +call\ s:setupdiff()' fnameescape (name)
59+ silent ! wincmd P
5760endfunction
0 commit comments