vim-signify/autoload/sy/sign.vim

58 lines
1.3 KiB
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: #get_others {{{1
function! sy#sign#get_others(path) abort
let s:other_signs_line_numbers = {}
2013-11-18 17:02:21 -05:00
let lang = v:lang
silent! execute 'language C'
2013-07-17 06:30:58 -04:00
redir => signlist
silent! execute 'sign place file='. a:path
redir END
for line in filter(split(signlist, '\n'), 'v:val =~ "^\\s\\+line"')
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
silent! execute 'language' 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-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)
continue
2013-07-17 06:30:58 -04:00
endif
call add(hunk.ids, g:id_top)
execute 'sign place' g:id_top 'line='. sign.lnum 'name='. sign.type 'file='. sign.path
2013-07-17 06:30:58 -04:00
let g:id_top += 1
endfor
2013-07-17 06:30:58 -04:00
call add(g:sy[sign.path].hunks, hunk)
endfunction
" Function: #remove_all {{{1
function! sy#sign#remove_all(path) abort
if g:signify_sign_overwrite
execute 'sign unplace * file='. a:path
else
for hunk in g:sy[a:path].hunks
for id in hunk.ids
execute 'sign unplace' id
endfor
2013-07-17 06:30:58 -04:00
endfor
endif
2013-07-17 06:30:58 -04:00
let g:sy[a:path].hunks = []
2013-08-26 11:52:29 -04:00
let g:sy[a:path].stats = [0, 0, 0]
2013-07-17 06:30:58 -04:00
endfunction