removed files
[~madcoder/dotfiles.git] / vim / ftplugin / gitcommit.vim
1 "=============================================================================
2 " Copyright:    Copyright © Pierre Habouzit
3 "               Permission is hereby granted to use and distribute this code,
4 "               with or without modifications, provided that this copyright
5 "               notice is copied with it. Like anything else that's free,
6 "               git.vim is provided *as is* and comes with no
7 "               warranty of any kind, either expressed or implied. In no
8 "               event will the copyright holder be liable for any damages
9 "               resulting from the use of this software.
10 " Description:  git-commit(1) helper
11 " Maintainer:   Pierre Habouzit <madcoder@debian.org>
12 " Last Changed: Mon, 26 Nov 2007 10:06:15 +0100
13 " Usage:        This file should live in your ftplugin directory.
14 "
15 "               The configurations variables are:
16 "
17 "                 g:git_diff_opts        - options to add to git diff,
18 "                                          (default "-C -C")
19 "                 g:git_diff_spawn_mode  - use auto-split on commit ?
20 "                                          * 1 == hsplit
21 "                                          * 2 == vsplit
22 "                                          * none else (default)
23 "
24 "               The default keymaping is:
25 "
26 "                 <Leader>gd   - view the diff in a hsplit
27 "                 <Leader>ghd  - view the diff in a hsplit
28 "                 <Leader>gvd  - view the diff in a vsplit
29 "========================================================================={{{=
30
31 if exists("b:did_ftplugin") | finish | endif
32
33 let b:did_ftplugin = 1
34
35 setlocal tw=74
36 setlocal nowarn nowb
37
38 function! Git_diff_windows(vertsplit, auto, opts)
39     if a:vertsplit
40         rightbelow vnew
41     else
42         rightbelow new
43     endif
44     silent! setlocal ft=diff previewwindow bufhidden=delete nobackup noswf nobuflisted nowrap buftype=nofile
45     exe "normal :r!cd .. && LANG=C git diff --stat -p --cached ".a:opts."\no\<esc>1GddO\<esc>"
46     setlocal nomodifiable
47     noremap <buffer> q :bw<cr>
48     if a:auto
49         redraw!
50         wincmd p
51         redraw!
52     endif
53 endfunction
54
55 noremap <buffer> <Leader>gd :call Git_diff_windows(0, 0)<cr>
56 noremap <buffer> <Leader>ghd :call Git_diff_windows(0, 0)<cr>
57 noremap <buffer> <Leader>gvd :call Git_diff_windows(1, 0)<cr>
58
59 if !exists("g:git_diff_opts")
60     let g:git_diff_opts = "-B -C -M"
61 endif
62 if exists("g:git_diff_spawn_mode")
63     if g:git_diff_spawn_mode == 1
64         call Git_diff_windows(0, 1, g:git_diff_opts)
65     elseif g:git_diff_spawn_mode == 2
66         call Git_diff_windows(1, 1, g:git_diff_opts)
67     endif
68 endif
69
70 func Eatchar(pat)
71     let c = nr2char(getchar(0))
72     return (c =~ a:pat) ? '' : c
73 endfunc
74
75 ia cc:  Cc-Redmine: yes<CR><C-R>=Eatchar('\s')<CR>
76 ia v:   Version:
77 ia sob: Signed-off-by:
78 ia ack: Acked-by:
79 ia r:   Reviewed-by:
80
81 " }}}