Mercurial > vim
comparison runtime/ftplugin/gitcommit.vim @ 2202:f7579a31705c vim73
Updated runtime files.
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Fri, 21 May 2010 12:05:36 +0200 |
parents | 7bc41231fbc7 |
children | 161d01cbb165 |
comparison
equal
deleted
inserted
replaced
2201:4c6b4298852f | 2202:f7579a31705c |
---|---|
1 " Vim filetype plugin | 1 " Vim filetype plugin |
2 " Language: git commit file | 2 " Language: git commit file |
3 " Maintainer: Tim Pope <vimNOSPAM@tpope.org> | 3 " Maintainer: Tim Pope <vimNOSPAM@tpope.org> |
4 " Last Change: 2009 Dec 24 | 4 " Last Change: 2010 May 21 |
5 | 5 |
6 " Only do this when not done yet for this buffer | 6 " Only do this when not done yet for this buffer |
7 if (exists("b:did_ftplugin")) | 7 if (exists("b:did_ftplugin")) |
8 finish | 8 finish |
9 endif | 9 endif |
13 | 13 |
14 if &textwidth == 0 | 14 if &textwidth == 0 |
15 " make sure that log messages play nice with git-log on standard terminals | 15 " make sure that log messages play nice with git-log on standard terminals |
16 setlocal textwidth=72 | 16 setlocal textwidth=72 |
17 if !exists("b:undo_ftplugin") | 17 if !exists("b:undo_ftplugin") |
18 let b:undo_ftplugin = "" | 18 let b:undo_ftplugin = "" |
19 endif | 19 endif |
20 let b:undo_ftplugin = b:undo_ftplugin . "|setl tw<" | 20 let b:undo_ftplugin = b:undo_ftplugin . "|setl tw<" |
21 endif | 21 endif |
22 | 22 |
23 if exists("g:no_gitcommit_commands") || v:version < 700 | 23 if exists("g:no_gitcommit_commands") || v:version < 700 |
24 finish | 24 finish |
25 endif | 25 endif |
26 | 26 |
27 if !exists("b:git_dir") | 27 if !exists("b:git_dir") |
28 let b:git_dir = expand("%:p:h") | 28 let b:git_dir = expand("%:p:h") |
29 endif | 29 endif |
30 | 30 |
31 " Automatically diffing can be done with: | 31 " Automatically diffing can be done with: |
32 " autocmd FileType gitcommit DiffGitCached | wincmd p | 32 " autocmd FileType gitcommit DiffGitCached | wincmd p |
33 command! -bang -bar -buffer -complete=custom,s:diffcomplete -nargs=* DiffGitCached :call s:gitdiffcached(<bang>0,b:git_dir,<f-args>) | 33 command! -bang -bar -buffer -complete=custom,s:diffcomplete -nargs=* DiffGitCached :call s:gitdiffcached(<bang>0,b:git_dir,<f-args>) |
34 | 34 |
35 function! s:diffcomplete(A,L,P) | 35 function! s:diffcomplete(A,L,P) |
36 let args = "" | 36 let args = "" |
37 if a:P <= match(a:L." -- "," -- ")+3 | 37 if a:P <= match(a:L." -- "," -- ")+3 |
38 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 let args = args . "-p\n--stat\n--shortstat\n--summary\n--patch-with-stat\n--no-renames\n-B\n-M\n-C\n" |
39 end | 39 end |
40 if exists("b:git_dir") && a:A !~ '^-' | 40 if exists("b:git_dir") && a:A !~ '^-' |
41 let tree = fnamemodify(b:git_dir,':h') | 41 let tree = fnamemodify(b:git_dir,':h') |
42 if strpart(getcwd(),0,strlen(tree)) == tree | 42 if strpart(getcwd(),0,strlen(tree)) == tree |
43 let args = args."\n".system("git diff --cached --name-only") | 43 let args = args."\n".system("git diff --cached --name-only") |
44 endif | |
45 endif | 44 endif |
46 return args | 45 endif |
46 return args | |
47 endfunction | 47 endfunction |
48 | 48 |
49 function! s:gitdiffcached(bang,gitdir,...) | 49 function! s:gitdiffcached(bang,gitdir,...) |
50 let tree = fnamemodify(a:gitdir,':h') | 50 let tree = fnamemodify(a:gitdir,':h') |
51 let name = tempname() | 51 let name = tempname() |
52 let git = "git" | 52 let git = "git" |
53 if strpart(getcwd(),0,strlen(tree)) != tree | 53 if strpart(getcwd(),0,strlen(tree)) != tree |
54 let git .= " --git-dir=".(exists("*shellescape") ? shellescape(a:gitdir) : '"'.a:gitdir.'"') | 54 let git .= " --git-dir=".(exists("*shellescape") ? shellescape(a:gitdir) : '"'.a:gitdir.'"') |
55 endif | 55 endif |
56 if a:0 | 56 if a:0 |
57 let extra = join(map(copy(a:000),exists("*shellescape") ? 'shellescape(v:val)' : "'\"'.v:val.'\"'")) | 57 let extra = join(map(copy(a:000),exists("*shellescape") ? 'shellescape(v:val)' : "'\"'.v:val.'\"'")) |
58 else | 58 else |
59 let extra = "-p --stat=".&columns | 59 let extra = "-p --stat=".&columns |
60 endif | 60 endif |
61 call system(git." diff --cached --no-color ".extra." > ".(exists("*shellescape") ? shellescape(name) : name)) | 61 call system(git." diff --cached --no-color ".extra." > ".(exists("*shellescape") ? shellescape(name) : name)) |
62 exe "pedit ".(exists("*fnameescape") ? fnameescape(name) : name) | 62 exe "pedit ".(exists("*fnameescape") ? fnameescape(name) : name) |
63 wincmd P | 63 wincmd P |
64 let b:git_dir = a:gitdir | 64 let b:git_dir = a:gitdir |
65 command! -bang -bar -buffer -complete=custom,s:diffcomplete -nargs=* DiffGitCached :call s:gitdiffcached(<bang>0,b:git_dir,<f-args>) | 65 command! -bang -bar -buffer -complete=custom,s:diffcomplete -nargs=* DiffGitCached :call s:gitdiffcached(<bang>0,b:git_dir,<f-args>) |
66 nnoremap <silent> q :q<CR> | 66 nnoremap <silent> q :q<CR> |
67 setlocal buftype=nowrite nobuflisted noswapfile nomodifiable filetype=git | 67 setlocal buftype=nowrite nobuflisted noswapfile nomodifiable filetype=git |
68 endfunction | 68 endfunction |