summaryrefslogtreecommitdiff
path: root/start/signify/autoload/sy/jump.vim
blob: 69756b1e07c57c59f59a31d3f3ebd3c3e416f712 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
" vim: et sw=2 sts=2

scriptencoding utf-8

" Function: #next_hunk {{{1
function! sy#jump#next_hunk(count)
  execute sy#util#return_if_no_changes()

  let lnum = line('.')
  let hunks = filter(copy(b:sy.hunks), 'v:val.start > lnum')
  let hunk = get(hunks, a:count - 1, get(hunks, -1, {}))

  if !empty(hunk)
    execute 'sign jump '. hunk.ids[0] .' buffer='. b:sy.buffer
  endif
endfunction

" Function: #prev_hunk {{{1
function! sy#jump#prev_hunk(count)
  execute sy#util#return_if_no_changes()

  let lnum = line('.')
  let hunks = filter(copy(b:sy.hunks), 'v:val.start < lnum')
  let hunk = get(hunks, 0 - a:count, get(hunks, 0, {}))

  if !empty(hunk)
    execute 'sign jump '. hunk.ids[0] .' buffer='. b:sy.buffer
  endif
endfunction