From ae8f77c22cafb4c1f14661cab7d53f99d342ed07 Mon Sep 17 00:00:00 2001 From: Philipp Hahn Date: Tue, 21 Jul 2020 09:25:38 +0200 Subject: [PATCH] Use sign groups "Coveragepy noshow" and "... refresh" did have no effect for me. Vim supports named group: Use them to group "[branch]uncovered" signs into them as it simplifies clearing previous signs. Switch "s:ClearSigns()" to use buffer number instead of file name. --- ftplugin/python/coveragepy.vim | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/ftplugin/python/coveragepy.vim b/ftplugin/python/coveragepy.vim index d8e6522..85d3905 100755 --- a/ftplugin/python/coveragepy.vim +++ b/ftplugin/python/coveragepy.vim @@ -32,7 +32,6 @@ let g:coveragepy_last_session = "" let g:coveragepy_marks = [] let g:coveragepy_session_map = {} let g:coveragepy_executable = "" -let s:sign_id = 9423 function! s:ToggleSigns() @@ -87,16 +86,8 @@ endfunction function! s:ClearSigns() abort - let placements = split(execute('sign place file=' . bufname('%')), '\n') - let fname = bufname('%') - for s in placements - let cols = split(s) - let name = split(cols[-1], '=')[-1] - if name[0:8] ==# 'uncovered' - let id = s:sign_id - exe printf('sign unplace %d file=%s', id, fname) - endif - endfor + execute("sign unplace * group=uncovered buffer=".bufnr('%')) + execute("sign unplace * group=branchuncovered buffer=".bufnr('%')) endfunction @@ -129,10 +120,10 @@ function! s:HighlightMissing() abort for path in keys(g:coveragepy_session_map) if (current_buffer =~ path) || (current_buffer_py =~ path) for position in g:coveragepy_session_map[path] - execute(":sign place ". s:sign_id ." line=". position ." name=uncovered buffer=".bufnr("%")) + execute(":sign place ". position ." line=". position ." group=uncovered name=uncovered buffer=".bufnr("%")) endfor for position in g:coveragepy_session_map['BRANCH' . path] - execute(":sign place ". s:sign_id ." line=". position ." name=branchuncovered buffer=".bufnr("%")) + execute(":sign place ". position ." line=". position ." group=branchuncovered name=branchuncovered buffer=".bufnr("%")) endfor " FIXME: I had to comment this out because it was no longer correct " after adding branch support