Mercurial > vim
annotate runtime/ftplugin/gitcommit.vim @ 20962:22b9f4afd1e2
Added tag v8.2.1032 for changeset 0e01976dfd3b226e10725a2d9d7894451e11e033
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 21 Jun 2020 20:45:04 +0200 |
parents | 5c40013d45ee |
children | 3e661b0cf500 |
rev | line source |
---|---|
1619 | 1 " Vim filetype plugin |
2034 | 2 " Language: git commit file |
3 " Maintainer: Tim Pope <vimNOSPAM@tpope.org> | |
18818 | 4 " Last Change: 2019 Dec 05 |
1619 | 5 |
6 " Only do this when not done yet for this buffer | |
7 if (exists("b:did_ftplugin")) | |
8 finish | |
9 endif | |
10 | |
11 runtime! ftplugin/git.vim | |
12 let b:did_ftplugin = 1 | |
13 | |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4681
diff
changeset
|
14 setlocal comments=:# commentstring=#\ %s |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4681
diff
changeset
|
15 setlocal nomodeline tabstop=8 formatoptions+=tl textwidth=72 |
18818 | 16 setlocal formatoptions-=c formatoptions-=r formatoptions-=o formatoptions-=q formatoptions+=n |
17 setlocal formatlistpat+=\\\|^\\s*[-*+]\\s\\+ | |
18 | |
19 let b:undo_ftplugin = 'setl modeline< tabstop< formatoptions< tw< com< cms< formatlistpat<' | |
1619 | 20 |
21 if exists("g:no_gitcommit_commands") || v:version < 700 | |
22 finish | |
23 endif | |
24 | |
25 if !exists("b:git_dir") | |
2202 | 26 let b:git_dir = expand("%:p:h") |
1619 | 27 endif |
28 | |
29 command! -bang -bar -buffer -complete=custom,s:diffcomplete -nargs=* DiffGitCached :call s:gitdiffcached(<bang>0,b:git_dir,<f-args>) | |
30 | |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4681
diff
changeset
|
31 let b:undo_ftplugin = b:undo_ftplugin . "|delc DiffGitCached" |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4681
diff
changeset
|
32 |
1619 | 33 function! s:diffcomplete(A,L,P) |
2202 | 34 let args = "" |
35 if a:P <= match(a:L." -- "," -- ")+3 | |
36 let args = args . "-p\n--stat\n--shortstat\n--summary\n--patch-with-stat\n--no-renames\n-B\n-M\n-C\n" | |
37 end | |
38 if exists("b:git_dir") && a:A !~ '^-' | |
39 let tree = fnamemodify(b:git_dir,':h') | |
40 if strpart(getcwd(),0,strlen(tree)) == tree | |
41 let args = args."\n".system("git diff --cached --name-only") | |
1619 | 42 endif |
2202 | 43 endif |
44 return args | |
1619 | 45 endfunction |
46 | |
47 function! s:gitdiffcached(bang,gitdir,...) | |
2202 | 48 let tree = fnamemodify(a:gitdir,':h') |
49 let name = tempname() | |
50 let git = "git" | |
51 if strpart(getcwd(),0,strlen(tree)) != tree | |
52 let git .= " --git-dir=".(exists("*shellescape") ? shellescape(a:gitdir) : '"'.a:gitdir.'"') | |
53 endif | |
54 if a:0 | |
55 let extra = join(map(copy(a:000),exists("*shellescape") ? 'shellescape(v:val)' : "'\"'.v:val.'\"'")) | |
56 else | |
57 let extra = "-p --stat=".&columns | |
58 endif | |
3465 | 59 call system(git." diff --cached --no-color --no-ext-diff ".extra." > ".(exists("*shellescape") ? shellescape(name) : name)) |
2202 | 60 exe "pedit ".(exists("*fnameescape") ? fnameescape(name) : name) |
61 wincmd P | |
62 let b:git_dir = a:gitdir | |
63 command! -bang -bar -buffer -complete=custom,s:diffcomplete -nargs=* DiffGitCached :call s:gitdiffcached(<bang>0,b:git_dir,<f-args>) | |
3465 | 64 nnoremap <buffer> <silent> q :q<CR> |
2202 | 65 setlocal buftype=nowrite nobuflisted noswapfile nomodifiable filetype=git |
1619 | 66 endfunction |