Skip to content
Snippets Groups Projects
Commit 4845ae07 authored by Jerome Reybert's avatar Jerome Reybert
Browse files

plugin/magit.vim: enlarge or shrink hunks fix #97

parent af1a1622
No related branches found
No related tags found
No related merge requests found
...@@ -224,6 +224,9 @@ E means 'edit'. ...@@ -224,6 +224,9 @@ E means 'edit'.
##### R ##### R
* Refresh magit buffer * Refresh magit buffer
##### -,+
* Shrink,enlarge diff context
##### q ##### q
* Close the magit buffer * Close the magit buffer
......
...@@ -117,8 +117,8 @@ function! magit#git#git_diff(filename, status, mode) ...@@ -117,8 +117,8 @@ function! magit#git#git_diff(filename, status, mode)
let dev_null = ( a:status == '?' ) ? "/dev/null " : "" let dev_null = ( a:status == '?' ) ? "/dev/null " : ""
let staged_flag = ( a:mode == 'staged' ) ? "--staged" : "" let staged_flag = ( a:mode == 'staged' ) ? "--staged" : ""
let git_cmd=g:magit_git_cmd . " diff --no-ext-diff " . staged_flag . let git_cmd=g:magit_git_cmd . " diff --no-ext-diff " . staged_flag .
\ " --no-color -p -- " . dev_null . " " \ " --no-color -p -U" . b:magit_diff_context .
\ . a:filename \ " -- " . dev_null . " " . a:filename
silent let diff_list=magit#utils#systemlist(git_cmd) silent let diff_list=magit#utils#systemlist(git_cmd)
if ( a:status != '?' && v:shell_error != 0 ) if ( a:status != '?' && v:shell_error != 0 )
echohl WarningMsg echohl WarningMsg
......
...@@ -265,6 +265,13 @@ Following mappings are set locally, for magit buffer only, in normal mode. ...@@ -265,6 +265,13 @@ Following mappings are set locally, for magit buffer only, in normal mode.
*vimagit-q* *vimagit-q*
*vimagit-g:magit_close_mapping* *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. q close magit buffer.
*vimagit-?* *magit#toggle_help()* *vimagit-?* *magit#toggle_help()*
......
...@@ -36,6 +36,9 @@ let g:magit_ignore_mapping = get(g:, 'magit_ignore_mapping', ...@@ -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_close_mapping = get(g:, 'magit_close_mapping', 'q' )
let g:magit_toggle_help_mapping = get(g:, 'magit_toggle_help_mapping', '?' ) 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_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_open_mapping = get(g:, 'magit_folding_open_mapping', [ 'zo', 'zO' ])
let g:magit_folding_close_mapping = get(g:, 'magit_folding_close_mapping', [ 'zc', 'zC' ]) let g:magit_folding_close_mapping = get(g:, 'magit_folding_close_mapping', [ 'zc', 'zC' ])
...@@ -114,6 +117,8 @@ let s:magit_inline_help = { ...@@ -114,6 +117,8 @@ let s:magit_inline_help = {
\. ' commit undo, cancel and close current commit message', \. ' commit undo, cancel and close current commit message',
\g:magit_reload_mapping \g:magit_reload_mapping
\.' refresh magit buffer', \.' refresh magit buffer',
\g:magit_diff_shrink.','.g:magit_diff_enlarge
\. ' shrink,enlarge diff context',
\g:magit_close_mapping \g:magit_close_mapping
\.' close magit buffer', \.' close magit buffer',
\g:magit_toggle_help_mapping \g:magit_toggle_help_mapping
...@@ -788,6 +793,8 @@ function! magit#show_magit(display, ...) ...@@ -788,6 +793,8 @@ function! magit#show_magit(display, ...)
let b:magit_current_commit_mode='' let b:magit_current_commit_mode=''
let b:magit_commit_newly_open=0 let b:magit_commit_newly_open=0
let b:magit_diff_context=3
call magit#utils#setbufnr(bufnr(buffer_name)) call magit#utils#setbufnr(bufnr(buffer_name))
call magit#sign#init() call magit#sign#init()
...@@ -802,6 +809,8 @@ function! magit#show_magit(display, ...) ...@@ -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_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_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_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_toggle_help_mapping . " :call magit#toggle_help()<cr>"
execute "nnoremap <buffer> <silent> " . g:magit_stage_line_mapping . " :call magit#stage_vselect()<cr>" execute "nnoremap <buffer> <silent> " . g:magit_stage_line_mapping . " :call magit#stage_vselect()<cr>"
...@@ -1173,6 +1182,15 @@ function! magit#jump_to() ...@@ -1173,6 +1182,15 @@ function! magit#jump_to()
execute "edit " . "+" . line . " " filename execute "edit " . "+" . line . " " filename
endfunction 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() function! magit#show_version()
return g:vimagit_version[0] . "." . return g:vimagit_version[0] . "." .
\ g:vimagit_version[1] . "." . \ g:vimagit_version[1] . "." .
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment