vim-signify/autoload/sy/jump.vim

36 lines
876 B
VimL
Raw Normal View History

2013-09-30 04:19:31 -04:00
" vim: et sw=2 sts=2
scriptencoding utf-8
2013-07-17 06:30:58 -04:00
" Function: #next_hunk {{{1
function! sy#jump#next_hunk(count)
if !has_key(g:sy, g:sy_path)
echomsg 'signify: I cannot detect any changes!'
return
endif
let lnum = line('.')
let hunks = filter(copy(g:sy[g:sy_path].hunks), 'v:val.start > lnum')
let hunk = get(hunks, a:count - 1, get(hunks, -1, {}))
2013-07-17 06:30:58 -04:00
if !empty(hunk)
execute 'sign jump '. hunk.ids[0] .' file='. g:sy_path
endif
endfunction
" Function: #prev_hunk {{{1
function! sy#jump#prev_hunk(count)
if !has_key(g:sy, g:sy_path)
echomsg 'signify: I cannot detect any changes!'
return
endif
let lnum = line('.')
let hunks = filter(copy(g:sy[g:sy_path].hunks), 'v:val.start < lnum')
let hunk = get(hunks, 0 - a:count, get(hunks, 0, {}))
2013-07-17 06:30:58 -04:00
if !empty(hunk)
execute 'sign jump '. hunk.ids[0] .' file='. g:sy_path
endif
endfunction