Skip to content

Commit

Permalink
plugin/magit.vim: enlarge or shrink hunks fix #97
Browse files Browse the repository at this point in the history
  • Loading branch information
jreybert committed Oct 12, 2016
1 parent af1a162 commit 4845ae0
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,9 @@ E means 'edit'.
##### R
* Refresh magit buffer

##### -,+
* Shrink,enlarge diff context

##### q
* Close the magit buffer

Expand Down
4 changes: 2 additions & 2 deletions autoload/magit/git.vim
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ function! magit#git#git_diff(filename, status, mode)
let dev_null = ( a:status == '?' ) ? "/dev/null " : ""
let staged_flag = ( a:mode == 'staged' ) ? "--staged" : ""
let git_cmd=g:magit_git_cmd . " diff --no-ext-diff " . staged_flag .
\ " --no-color -p -- " . dev_null . " "
\ . a:filename
\ " --no-color -p -U" . b:magit_diff_context .
\ " -- " . dev_null . " " . a:filename
silent let diff_list=magit#utils#systemlist(git_cmd)
if ( a:status != '?' && v:shell_error != 0 )
echohl WarningMsg
Expand Down
7 changes: 7 additions & 0 deletions doc/vimagit.txt
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,13 @@ Following mappings are set locally, for magit buffer only, in normal mode.

*vimagit-q*
*vimagit-g:magit_close_mapping*

*vimagit--* *magit#update_diff()*
*vimagit-+*
*vimagit-g:magit_diff_shrink*
*vimagit-g:magit_diff_enlarge*
-,+ Shrink,enlarge diff context

q close magit buffer.

*vimagit-?* *magit#toggle_help()*
Expand Down
18 changes: 18 additions & 0 deletions plugin/magit.vim
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ let g:magit_ignore_mapping = get(g:, 'magit_ignore_mapping',
let g:magit_close_mapping = get(g:, 'magit_close_mapping', 'q' )
let g:magit_toggle_help_mapping = get(g:, 'magit_toggle_help_mapping', '?' )

let g:magit_diff_shrink = get(g:, 'magit_diff_shrink', '-' )
let g:magit_diff_enlarge = get(g:, 'magit_diff_enlarge', '+' )

let g:magit_folding_toggle_mapping = get(g:, 'magit_folding_toggle_mapping', [ '<CR>' ])
let g:magit_folding_open_mapping = get(g:, 'magit_folding_open_mapping', [ 'zo', 'zO' ])
let g:magit_folding_close_mapping = get(g:, 'magit_folding_close_mapping', [ 'zc', 'zC' ])
Expand Down Expand Up @@ -114,6 +117,8 @@ let s:magit_inline_help = {
\. ' commit undo, cancel and close current commit message',
\g:magit_reload_mapping
\.' refresh magit buffer',
\g:magit_diff_shrink.','.g:magit_diff_enlarge
\. ' shrink,enlarge diff context',
\g:magit_close_mapping
\.' close magit buffer',
\g:magit_toggle_help_mapping
Expand Down Expand Up @@ -788,6 +793,8 @@ function! magit#show_magit(display, ...)
let b:magit_current_commit_mode=''
let b:magit_commit_newly_open=0

let b:magit_diff_context=3

call magit#utils#setbufnr(bufnr(buffer_name))
call magit#sign#init()

Expand All @@ -802,6 +809,8 @@ function! magit#show_magit(display, ...)
execute "nnoremap <buffer> <silent> " . g:magit_close_commit_mapping . " :call magit#close_commit()<cr>"
execute "nnoremap <buffer> <silent> " . g:magit_ignore_mapping . " :call magit#ignore_file()<cr>"
execute "nnoremap <buffer> <silent> " . g:magit_close_mapping . " :call magit#close_magit()<cr>"
execute "nnoremap <buffer> <silent> " . g:magit_diff_shrink . " :call magit#update_diff('-')<cr>"
execute "nnoremap <buffer> <silent> " . g:magit_diff_enlarge . " :call magit#update_diff('+')<cr>"
execute "nnoremap <buffer> <silent> " . g:magit_toggle_help_mapping . " :call magit#toggle_help()<cr>"

execute "nnoremap <buffer> <silent> " . g:magit_stage_line_mapping . " :call magit#stage_vselect()<cr>"
Expand Down Expand Up @@ -1173,6 +1182,15 @@ function! magit#jump_to()
execute "edit " . "+" . line . " " filename
endfunction

function! magit#update_diff(way)
if ( a:way == "+" )
let b:magit_diff_context+=1
elseif ( b:magit_diff_context > 1 )
let b:magit_diff_context-=1
endif
call magit#update_buffer()
endfunction

function! magit#show_version()
return g:vimagit_version[0] . "." .
\ g:vimagit_version[1] . "." .
Expand Down

0 comments on commit 4845ae0

Please sign in to comment.