Added vim-fugitive and vim-gitgutter

This commit is contained in:
Emmanuel BENOîT 2015-03-09 11:52:35 +01:00
parent 7450d476a1
commit bb3b634ed8
6 changed files with 57 additions and 0 deletions

View file

@ -1,4 +1,5 @@
" NERDTree: ' e' = toggle side bar
let g:NERDTreeUpdateOnWrite = 1
nnoremap <Leader>e :NERDTreeToggle<CR>
" Open automatically if there are more than 150 columns and no file was specified

View file

@ -0,0 +1,13 @@
" Fugitive commands that don't require interaction with GitGutter or NERDTree
nnoremap <silent> <Leader>gd :Gdiff<cr>
nnoremap <silent> <Leader>gs :Gstatus<cr>
nnoremap <silent> <Leader>gl :Silent Glog<cr>:bot copen<cr>
nnoremap <silent> <Leader>gc :Gcommit -q<cr>
nnoremap <Leader>gb :Git branch<space>
" Note: dangerous commands don't have a <cr>
nnoremap <Leader>gB :Git checkout -b<space>
nnoremap <Leader>gC :Git checkout<space>
nnoremap <Leader>gM :Gmove<space>
nnoremap <Leader>gP :Git push<space>
nnoremap <Leader>gR :Gremove

View file

@ -0,0 +1 @@
NeoBundle 'tpope/vim-fugitive'

View file

@ -0,0 +1,23 @@
function! <SID>RunGitOp(op)
execute "Silent" a:op
GitGutter
let wins = filter( range( 1 , winnr( '$' ) ) ,
\ "buffer_name(winbufnr(v:val)) =~ '^NERD_tree_[0-9]\\+$'" )
if empty( l:wins )
return
endif
let wn = winnr()
call NERDTreeFocus()
call feedkeys( "R:" . l:wn . "wincmd w\<cr>:\<esc>" , 't' )
endfunction
let g:gitgutter_map_keys = 0
nnoremap <silent> <Leader>g< :GitGutterPrevHunk<cr>
nnoremap <silent> <Leader>g> :GitGutterNextHunk<cr>
nnoremap <silent> <Leader>g+ :call <SID>RunGitOp( 'GitGutterStageHunk' )<cr>
nnoremap <Leader>g- :GitGutterRevertHunk
nnoremap <silent> <Leader>ga :call <SID>RunGitOp( 'Git add %:p' )<cr>

View file

@ -0,0 +1 @@
NeoBundle 'airblade/vim-gitgutter'

View file

@ -42,3 +42,21 @@ local leader key.
<Leader>t Toggle tagbar
<Leader>e Toggle NERDtree explorer
<Leader>gd Git: view diff for current buffer
<Leader>gl Git: show log
<Leader>gs Git: show status
<Leader>g< Git: previous modified chunk
<Leader>g> Git: next modified chunk
<Leader>g+ Git: add modified chunk
<Leader>g- Git: revert modified chunk
<Leader>ga Git: add whole buffer
<Leader>gb Git: create branch
<Leader>gc Git: commit staged changes
<Leader>gB Git: create and checkout branch
<Leader>gC Git: checkout
<Leader>gM Git: rename current buffer
<Leader>gP Git: push
<Leader>gR Git: remove current buffer