diff --git a/autoload/sy.vim b/autoload/sy.vim index 14fa1a0..91362b9 100644 --- a/autoload/sy.vim +++ b/autoload/sy.vim @@ -57,11 +57,6 @@ function! sy#start(path) abort call sy#repo#process_diff(a:path, diff) sign unplace 99999 - if !maparg('[c', 'n') - nnoremap ]c :execute v:count1 .'SignifyJumpToNextHunk' - nnoremap [c :execute v:count1 .'SignifyJumpToPrevHunk' - endif - let g:sy[a:path].id_top = (g:id_top - 1) endfunction diff --git a/doc/signify.txt b/doc/signify.txt index 8e0fe02..4464491 100644 --- a/doc/signify.txt +++ b/doc/signify.txt @@ -123,6 +123,14 @@ Don't run Sy by default. You can toggle it anytime via :SignifyToggle. Mapping for jumping to the start of the next or previous hunk. +Alternatively, you can also map it yourself: + + nmap gj (signify-next-jump) + nmap gk (signify-prev-jump) + +There is no difference between both variants. + + ============- let g:signify_mapping_toggle_highlight = 'gh' @@ -217,24 +225,6 @@ Default mapping: gt Toggle line highlighting for lines containing changes. Default mapping: gh -============- - - :SignifyJumpToNextHunk - -Jump to the next start of a hunk. There are two mappings available: - -Hardcoded mapping: ]c -Configurable mapping: gj - -============- - - :SignifyJumpToPrevHunk - -Jump to the previous start of a hunk. There are two mappings available: - -Hardcoded mapping: [c -Configurable mapping: gk - ============================================================================== 5. Colors *signify-colors* diff --git a/plugin/signify.vim b/plugin/signify.vim index 6e50fa4..dc96d61 100644 --- a/plugin/signify.vim +++ b/plugin/signify.vim @@ -53,40 +53,46 @@ augroup signify augroup END " Init: commands {{{1 -com! -nargs=0 -bar SignifyToggle call sy#toggle() -com! -nargs=0 -bar SignifyToggleHighlight call sy#highlight#line_toggle() -com! -nargs=0 -bar -count=1 SignifyJumpToNextHunk call sy#jump#next_hunk() -com! -nargs=0 -bar -count=1 SignifyJumpToPrevHunk call sy#jump#prev_hunk() -com! -nargs=0 -bar SyDebug call sy#debug#list_active_buffers() +com! -nargs=0 -bar SignifyToggle call sy#toggle() +com! -nargs=0 -bar SignifyToggleHighlight call sy#highlight#line_toggle() +com! -nargs=0 -bar SyDebug call sy#debug#list_active_buffers() " Init: mappings {{{1 -nnoremap (signify-next-hunk) :call sy#jump#next_hunk(v:count1) -nnoremap (signify-prev-hunk) :call sy#jump#prev_hunk(v:count1) -nnoremap (signify-toggle-highlight) :call sy#highlight#line_toggle() -nnoremap (signify-toggle) :call sy#toggle() +nnoremap (signify-next-hunk) &diff ? ']c' : ":\call sy#jump#next_hunk(v:count1)\" +nnoremap (signify-prev-hunk) &diff ? '[c' : ":\call sy#jump#prev_hunk(v:count1)\" +nnoremap (signify-toggle-highlight) :call sy#highlight#line_toggle() +nnoremap (signify-toggle) :call sy#toggle() if exists('g:signify_mapping_next_hunk') - execute 'nnoremap '. g:signify_mapping_next_hunk .' (signify-next-hunk)' -elseif !hasmapto('(signify-next-hunk)') && empty(maparg('gj', 'n')) - nnoremap gj (signify-next-hunk) + execute 'nmap '. g:signify_mapping_next_hunk .' (signify-next-hunk)' +elseif !hasmapto('(signify-next-hunk)') && !maparg('gj', 'n') + nmap gj (signify-next-hunk) endif if exists('g:signify_mapping_prev_hunk') - execute 'nnoremap '. g:signify_mapping_prev_hunk .' (signify-prev-hunk)' -elseif !hasmapto('(signify-prev-hunk)') && empty(maparg('gk', 'n')) - nnoremap gk (signify-prev-hunk) + execute 'nmap '. g:signify_mapping_prev_hunk .' (signify-prev-hunk)' +elseif !hasmapto('(signify-prev-hunk)') && !maparg('gk', 'n') + nmap gk (signify-prev-hunk) endif if exists('g:signify_mapping_toggle_highlight') - execute 'nnoremap '. g:signify_mapping_toggle_highlight .' (signify-toggle-highlight)' -elseif !hasmapto('(signify-toggle-highlight)') && empty(maparg('gh', 'n')) - nnoremap gh (signify-toggle-highlight) + execute 'nmap '. g:signify_mapping_toggle_highlight .' (signify-toggle-highlight)' +elseif !hasmapto('(signify-toggle-highlight)') && !maparg('gh', 'n') + nmap gh (signify-toggle-highlight) endif if exists('g:signify_mapping_toggle') - execute 'nnoremap '. g:signify_mapping_toggle .' (signify-toggle)' -elseif !hasmapto('(signify-toggle)') && empty(maparg('gt', 'n')) - nnoremap gt (signify-toggle) + execute 'nmap '. g:signify_mapping_toggle .' (signify-toggle)' +elseif !hasmapto('(signify-toggle)') && !maparg('gt', 'n') + nmap gt (signify-toggle) +endif + +if !maparg(']c', 'n') + nmap ]c (signify-next-hunk) +endif + +if !maparg('[c', 'n') + nmap [c (signify-prev-hunk) endif " vim: et sw=2 sts=2