annotate runtime/ftplugin/gitcommit.vim @ 18039:ef5720fb6f41 v8.1.2015

patch 8.1.2015: terminal altscreen test still fails sometimes Commit: https://github.com/vim/vim/commit/bf9a3b0164e649b357d6218b4358208288b6fb7e Author: Bram Moolenaar <Bram@vim.org> Date: Sun Sep 8 22:35:48 2019 +0200 patch 8.1.2015: terminal altscreen test still fails sometimes Problem: Terminal altscreen test still fails sometimes. Solution: Write the escape sequence in a file.
author Bram Moolenaar <Bram@vim.org>
date Sun, 08 Sep 2019 22:45:03 +0200
parents 43efa4f5a8ea
children 5c40013d45ee
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1619
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
1 " Vim filetype plugin
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1619
diff changeset
2 " Language: git commit file
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1619
diff changeset
3 " Maintainer: Tim Pope <vimNOSPAM@tpope.org>
10048
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 4681
diff changeset
4 " Last Change: 2016 Aug 29
1619
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
5
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
6 " Only do this when not done yet for this buffer
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
7 if (exists("b:did_ftplugin"))
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
8 finish
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
9 endif
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
10
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
11 runtime! ftplugin/git.vim
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
12 let b:did_ftplugin = 1
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
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
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 4681
diff changeset
16 setlocal formatoptions-=c formatoptions-=r formatoptions-=o formatoptions-=q
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 4681
diff changeset
17 let b:undo_ftplugin = 'setl modeline< tabstop< formatoptions< tw< com< cms<'
1619
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
18
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
19 if exists("g:no_gitcommit_commands") || v:version < 700
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
20 finish
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
21 endif
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
22
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
23 if !exists("b:git_dir")
2202
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
24 let b:git_dir = expand("%:p:h")
1619
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
25 endif
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
26
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
27 command! -bang -bar -buffer -complete=custom,s:diffcomplete -nargs=* DiffGitCached :call s:gitdiffcached(<bang>0,b:git_dir,<f-args>)
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
28
10048
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 4681
diff changeset
29 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
30
1619
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
31 function! s:diffcomplete(A,L,P)
2202
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
32 let args = ""
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
33 if a:P <= match(a:L." -- "," -- ")+3
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
34 let args = args . "-p\n--stat\n--shortstat\n--summary\n--patch-with-stat\n--no-renames\n-B\n-M\n-C\n"
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
35 end
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
36 if exists("b:git_dir") && a:A !~ '^-'
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
37 let tree = fnamemodify(b:git_dir,':h')
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
38 if strpart(getcwd(),0,strlen(tree)) == tree
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
39 let args = args."\n".system("git diff --cached --name-only")
1619
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
40 endif
2202
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
41 endif
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
42 return args
1619
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
43 endfunction
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
44
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
45 function! s:gitdiffcached(bang,gitdir,...)
2202
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
46 let tree = fnamemodify(a:gitdir,':h')
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
47 let name = tempname()
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
48 let git = "git"
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
49 if strpart(getcwd(),0,strlen(tree)) != tree
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
50 let git .= " --git-dir=".(exists("*shellescape") ? shellescape(a:gitdir) : '"'.a:gitdir.'"')
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
51 endif
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
52 if a:0
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
53 let extra = join(map(copy(a:000),exists("*shellescape") ? 'shellescape(v:val)' : "'\"'.v:val.'\"'"))
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
54 else
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
55 let extra = "-p --stat=".&columns
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
56 endif
3465
161d01cbb165 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2202
diff changeset
57 call system(git." diff --cached --no-color --no-ext-diff ".extra." > ".(exists("*shellescape") ? shellescape(name) : name))
2202
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
58 exe "pedit ".(exists("*fnameescape") ? fnameescape(name) : name)
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
59 wincmd P
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
60 let b:git_dir = a:gitdir
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
61 command! -bang -bar -buffer -complete=custom,s:diffcomplete -nargs=* DiffGitCached :call s:gitdiffcached(<bang>0,b:git_dir,<f-args>)
3465
161d01cbb165 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2202
diff changeset
62 nnoremap <buffer> <silent> q :q<CR>
2202
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
63 setlocal buftype=nowrite nobuflisted noswapfile nomodifiable filetype=git
1619
b9740fb41986 updated for version 7.2a
vimboss
parents:
diff changeset
64 endfunction