2013-09-30 04:19:31 -04:00
|
|
|
" vim: et sw=2 sts=2
|
|
|
|
|
2013-08-19 11:36:16 -04:00
|
|
|
scriptencoding utf-8
|
|
|
|
|
2013-12-05 19:51:33 -05:00
|
|
|
" Init: values {{{1
|
|
|
|
let s:delete_highlight = ['', 'SignifyLineDelete']
|
|
|
|
|
2013-07-17 06:30:58 -04:00
|
|
|
" Function: #get_others {{{1
|
2013-11-21 20:57:43 -05:00
|
|
|
function! sy#sign#get_others() abort
|
2013-09-06 10:22:09 -04:00
|
|
|
let s:other_signs_line_numbers = {}
|
|
|
|
|
2013-11-18 17:02:21 -05:00
|
|
|
let lang = v:lang
|
2014-02-04 12:32:22 -05:00
|
|
|
silent! execute 'language message C'
|
2013-11-18 17:02:21 -05:00
|
|
|
|
2013-07-17 06:30:58 -04:00
|
|
|
redir => signlist
|
2013-11-21 20:57:43 -05:00
|
|
|
silent! execute 'sign place buffer='. b:sy.buffer
|
2013-07-17 06:30:58 -04:00
|
|
|
redir END
|
|
|
|
|
2013-12-06 16:43:51 -05:00
|
|
|
let lines = filter(split(signlist, '\n'), 'v:val =~ "^\\s\\+line"')
|
|
|
|
|
|
|
|
if lines[0] =~ 99999
|
|
|
|
call remove(lines, 0)
|
|
|
|
endif
|
|
|
|
|
|
|
|
for line in lines
|
2013-07-17 06:30:58 -04:00
|
|
|
let lnum = matchlist(line, '\v^\s+line\=(\d+)')[1]
|
|
|
|
let s:other_signs_line_numbers[lnum] = 1
|
|
|
|
endfor
|
2013-11-18 17:02:21 -05:00
|
|
|
|
2014-02-04 12:32:22 -05:00
|
|
|
silent! execute 'language message' lang
|
2013-07-17 06:30:58 -04:00
|
|
|
endfunction
|
|
|
|
|
|
|
|
" Function: #set {{{1
|
|
|
|
function! sy#sign#set(signs)
|
|
|
|
let hunk = { 'ids': [], 'start': a:signs[0].lnum, 'end': a:signs[-1].lnum }
|
2013-09-06 09:34:13 -04:00
|
|
|
|
2013-07-17 06:30:58 -04:00
|
|
|
for sign in a:signs
|
|
|
|
" Preserve non-signify signs
|
|
|
|
if !g:signify_sign_overwrite && has_key(s:other_signs_line_numbers, sign.lnum)
|
2013-09-06 09:34:13 -04:00
|
|
|
continue
|
2013-07-17 06:30:58 -04:00
|
|
|
endif
|
|
|
|
|
|
|
|
call add(hunk.ids, g:id_top)
|
2014-01-03 20:06:25 -05:00
|
|
|
if sign.type =~# 'SignifyDelete'
|
|
|
|
execute 'sign define '. sign.type .' text='. sign.text .' texthl=SignifySignDelete linehl='. s:delete_highlight[g:signify_line_highlight]
|
|
|
|
execute 'sign place' g:id_top 'line='. sign.lnum 'name='. sign.type 'buffer='. b:sy.buffer
|
2013-12-05 19:51:33 -05:00
|
|
|
else
|
|
|
|
execute 'sign place' g:id_top 'line='. sign.lnum 'name='. sign.type 'buffer='. b:sy.buffer
|
|
|
|
endif
|
2013-07-17 06:30:58 -04:00
|
|
|
|
|
|
|
let g:id_top += 1
|
|
|
|
endfor
|
2013-09-06 09:34:13 -04:00
|
|
|
|
2013-11-21 20:57:43 -05:00
|
|
|
call add(b:sy.hunks, hunk)
|
2013-07-17 06:30:58 -04:00
|
|
|
endfunction
|
|
|
|
|
|
|
|
" Function: #remove_all {{{1
|
2013-11-21 20:57:43 -05:00
|
|
|
function! sy#sign#remove_all(bnum) abort
|
2013-11-22 10:44:00 -05:00
|
|
|
let sy = getbufvar(a:bnum, 'sy')
|
|
|
|
|
2013-09-06 09:34:13 -04:00
|
|
|
if g:signify_sign_overwrite
|
2013-11-22 10:44:00 -05:00
|
|
|
execute 'sign unplace * buffer='. sy.buffer
|
2013-09-06 09:34:13 -04:00
|
|
|
else
|
2013-11-22 10:44:00 -05:00
|
|
|
for hunk in sy.hunks
|
2013-09-06 09:34:13 -04:00
|
|
|
for id in hunk.ids
|
|
|
|
execute 'sign unplace' id
|
|
|
|
endfor
|
2013-07-17 06:30:58 -04:00
|
|
|
endfor
|
2013-09-06 09:34:13 -04:00
|
|
|
endif
|
2013-07-17 06:30:58 -04:00
|
|
|
|
2013-11-22 10:44:00 -05:00
|
|
|
let sy.hunks = []
|
|
|
|
let sy.stats = [0, 0, 0]
|
2013-07-17 06:30:58 -04:00
|
|
|
endfunction
|