" Vim filetype plugin" Language: git commit file" Maintainer: Tim Pope <vimNOSPAM@tpope.org>" Last Change: 2016 Aug 29" Only do this when not done yet for this bufferif (exists("b:did_ftplugin"))finishendifruntime! ftplugin/git.vimlet b:did_ftplugin = 1setlocal comments=:# commentstring=#\ %ssetlocal nomodeline tabstop=8 formatoptions+=tl textwidth=72setlocal formatoptions-=c formatoptions-=r formatoptions-=o formatoptions-=qlet b:undo_ftplugin = 'setl modeline< tabstop< formatoptions< tw< com< cms<'if exists("g:no_gitcommit_commands") || v:version < 700finishendifif !exists("b:git_dir")let b:git_dir = expand("%:p:h")endifcommand! -bang -bar -buffer -complete=custom,s:diffcomplete -nargs=* DiffGitCached :call s:gitdiffcached(<bang>0,b:git_dir,<f-args>)let b:undo_ftplugin = b:undo_ftplugin . "|delc DiffGitCached"function! s:diffcomplete(A,L,P)let args = ""if a:P <= match(a:L." -- "," -- ")+3let args = args . "-p\n--stat\n--shortstat\n--summary\n--patch-with-stat\n--no-renames\n-B\n-M\n-C\n"endif exists("b:git_dir") && a:A !~ '^-'let tree = fnamemodify(b:git_dir,':h')if strpart(getcwd(),0,strlen(tree)) == treelet args = args."\n".system("git diff --cached --name-only")endifendifreturn argsendfunctionfunction! s:gitdiffcached(bang,gitdir,...)let tree = fnamemodify(a:gitdir,':h')let name = tempname()let git = "git"if strpart(getcwd(),0,strlen(tree)) != treelet git .= " --git-dir=".(exists("*shellescape") ? shellescape(a:gitdir) : '"'.a:gitdir.'"')endifif a:0let extra = join(map(copy(a:000),exists("*shellescape") ? 'shellescape(v:val)' : "'\"'.v:val.'\"'"))elselet extra = "-p --stat=".&columnsendifcall system(git." diff --cached --no-color --no-ext-diff ".extra." > ".(exists("*shellescape") ? shellescape(name) : name))exe "pedit ".(exists("*fnameescape") ? fnameescape(name) : name)wincmd Plet b:git_dir = a:gitdircommand! -bang -bar -buffer -complete=custom,s:diffcomplete -nargs=* DiffGitCached :call s:gitdiffcached(<bang>0,b:git_dir,<f-args>)nnoremap <buffer> <silent> q :q<CR>setlocal buftype=nowrite nobuflisted noswapfile nomodifiable filetype=gitendfunction
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。