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.
15 " The configurations variables are:
17 " g:git_diff_opts - options to add to git diff,
19 " g:git_diff_spawn_mode - use auto-split on commit ?
22 " * none else (default)
24 " The default keymaping is:
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 "========================================================================={{{=
31 if exists("b:did_ftplugin") | finish | endif
33 let b:did_ftplugin = 1
38 function! Git_diff_windows(vertsplit, auto, opts)
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>"
47 noremap <buffer> q :bw<cr>
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>
59 if !exists("g:git_diff_opts")
60 let g:git_diff_opts = "-B -C -M"
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)