Improve jumping once again

References #4.
This commit is contained in:
Marco Hinz 2013-07-22 00:21:34 +02:00
parent 4b1dc081d7
commit 9733f6cfac
3 changed files with 35 additions and 44 deletions

View File

@ -57,11 +57,6 @@ function! sy#start(path) abort
call sy#repo#process_diff(a:path, diff) call sy#repo#process_diff(a:path, diff)
sign unplace 99999 sign unplace 99999
if !maparg('[c', 'n')
nnoremap <buffer><silent> ]c :<c-u>execute v:count1 .'SignifyJumpToNextHunk'<cr>
nnoremap <buffer><silent> [c :<c-u>execute v:count1 .'SignifyJumpToPrevHunk'<cr>
endif
let g:sy[a:path].id_top = (g:id_top - 1) let g:sy[a:path].id_top = (g:id_top - 1)
endfunction endfunction

View File

@ -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. Mapping for jumping to the start of the next or previous hunk.
Alternatively, you can also map it yourself:
nmap <leader>gj <plug>(signify-next-jump)
nmap <leader>gk <plug>(signify-prev-jump)
There is no difference between both variants.
============- ============-
let g:signify_mapping_toggle_highlight = '<leader>gh' let g:signify_mapping_toggle_highlight = '<leader>gh'
@ -217,24 +225,6 @@ Default mapping: <leader>gt
Toggle line highlighting for lines containing changes. Toggle line highlighting for lines containing changes.
Default mapping: <leader>gh Default mapping: <leader>gh
============-
:SignifyJumpToNextHunk
Jump to the next start of a hunk. There are two mappings available:
Hardcoded mapping: ]c
Configurable mapping: <leader>gj
============-
:SignifyJumpToPrevHunk
Jump to the previous start of a hunk. There are two mappings available:
Hardcoded mapping: [c
Configurable mapping: <leader>gk
============================================================================== ==============================================================================
5. Colors *signify-colors* 5. Colors *signify-colors*

View File

@ -55,38 +55,44 @@ augroup END
" Init: commands {{{1 " Init: commands {{{1
com! -nargs=0 -bar SignifyToggle call sy#toggle() com! -nargs=0 -bar SignifyToggle call sy#toggle()
com! -nargs=0 -bar SignifyToggleHighlight call sy#highlight#line_toggle() com! -nargs=0 -bar SignifyToggleHighlight call sy#highlight#line_toggle()
com! -nargs=0 -bar -count=1 SignifyJumpToNextHunk call sy#jump#next_hunk(<count>)
com! -nargs=0 -bar -count=1 SignifyJumpToPrevHunk call sy#jump#prev_hunk(<count>)
com! -nargs=0 -bar SyDebug call sy#debug#list_active_buffers() com! -nargs=0 -bar SyDebug call sy#debug#list_active_buffers()
" Init: mappings {{{1 " Init: mappings {{{1
nnoremap <silent> <plug>(signify-next-hunk) :<C-u>call sy#jump#next_hunk(v:count1)<cr> nnoremap <silent> <expr> <plug>(signify-next-hunk) &diff ? ']c' : ":\<c-u>call sy#jump#next_hunk(v:count1)\<cr>"
nnoremap <silent> <plug>(signify-prev-hunk) :<C-u>call sy#jump#prev_hunk(v:count1)<cr> nnoremap <silent> <expr> <plug>(signify-prev-hunk) &diff ? '[c' : ":\<c-u>call sy#jump#prev_hunk(v:count1)\<cr>"
nnoremap <silent> <plug>(signify-toggle-highlight) :<C-u>call sy#highlight#line_toggle()<cr> nnoremap <silent> <plug>(signify-toggle-highlight) :<c-u>call sy#highlight#line_toggle()<cr>
nnoremap <silent> <plug>(signify-toggle) :<C-u>call sy#toggle()<cr> nnoremap <silent> <plug>(signify-toggle) :<c-u>call sy#toggle()<cr>
if exists('g:signify_mapping_next_hunk') if exists('g:signify_mapping_next_hunk')
execute 'nnoremap '. g:signify_mapping_next_hunk .' <plug>(signify-next-hunk)' execute 'nmap '. g:signify_mapping_next_hunk .' <plug>(signify-next-hunk)'
elseif !hasmapto('<plug>(signify-next-hunk)') && empty(maparg('<leader>gj', 'n')) elseif !hasmapto('<plug>(signify-next-hunk)') && !maparg('<leader>gj', 'n')
nnoremap <leader>gj <plug>(signify-next-hunk) nmap <leader>gj <plug>(signify-next-hunk)
endif endif
if exists('g:signify_mapping_prev_hunk') if exists('g:signify_mapping_prev_hunk')
execute 'nnoremap '. g:signify_mapping_prev_hunk .' <plug>(signify-prev-hunk)' execute 'nmap '. g:signify_mapping_prev_hunk .' <plug>(signify-prev-hunk)'
elseif !hasmapto('<plug>(signify-prev-hunk)') && empty(maparg('<leader>gk', 'n')) elseif !hasmapto('<plug>(signify-prev-hunk)') && !maparg('<leader>gk', 'n')
nnoremap <leader>gk <plug>(signify-prev-hunk) nmap <leader>gk <plug>(signify-prev-hunk)
endif endif
if exists('g:signify_mapping_toggle_highlight') if exists('g:signify_mapping_toggle_highlight')
execute 'nnoremap '. g:signify_mapping_toggle_highlight .' <plug>(signify-toggle-highlight)' execute 'nmap '. g:signify_mapping_toggle_highlight .' <plug>(signify-toggle-highlight)'
elseif !hasmapto('<plug>(signify-toggle-highlight)') && empty(maparg('<leader>gh', 'n')) elseif !hasmapto('<plug>(signify-toggle-highlight)') && !maparg('<leader>gh', 'n')
nnoremap <leader>gh <plug>(signify-toggle-highlight) nmap <leader>gh <plug>(signify-toggle-highlight)
endif endif
if exists('g:signify_mapping_toggle') if exists('g:signify_mapping_toggle')
execute 'nnoremap '. g:signify_mapping_toggle .' <plug>(signify-toggle)' execute 'nmap '. g:signify_mapping_toggle .' <plug>(signify-toggle)'
elseif !hasmapto('<plug>(signify-toggle)') && empty(maparg('<leader>gt', 'n')) elseif !hasmapto('<plug>(signify-toggle)') && !maparg('<leader>gt', 'n')
nnoremap <leader>gt <plug>(signify-toggle) nmap <leader>gt <plug>(signify-toggle)
endif
if !maparg(']c', 'n')
nmap ]c <plug>(signify-next-hunk)
endif
if !maparg('[c', 'n')
nmap [c <plug>(signify-prev-hunk)
endif endif
" vim: et sw=2 sts=2 " vim: et sw=2 sts=2