mgedmin / coverage-highlight.vim

Vim plugin to highlight Python source code lines that lack test coverage
MIT License
56 stars 5 forks source link

HighlightCoverageOff does not work in neovim #10

Closed diefans closed 5 years ago

diefans commented 5 years ago

:HighlightCoverageOffis doing nothing while running :sign unplace <id> works.

I am using neovim, what might be the cause... Neovim's RPC machine is not propagating a change to a list in a buffer.vars item back to the core. So placed signs get never stored in the buffer's vars.

The following diff fixes the problem:

diff --git a/pythonx/coverage_highlight.py b/pythonx/coverage_highlight.py
index 5472a4a..ed27642 100644
--- a/pythonx/coverage_highlight.py
+++ b/pythonx/coverage_highlight.py
@@ -87,6 +87,7 @@ class Signs(object):
         vim.command(cmd)
         # vim.List has no .append()
         self.signs.extend([self.signid])
+        vim.current.buffer.vars['coverage-highlight.vim:coverage_signs'] = self.signs

     def place_branch(self, src_lineno, dst_lineno):
         key = str(src_lineno)
mgedmin commented 5 years ago

Ooh, interesting!

I wonder if the same kind of update needs to be done to make branch coverage messages work.

mgedmin commented 5 years ago

A way to test:

  1. create a sample.py:
def make_even(x):
    if x % 2 == 1:
        x += 1
    return x
  1. run :HighlightCoverage 2->4
  2. move the cursor to line 2

you should see "Line 2: missing branch to 4" in the bottom area

ekrano nuotrauka is 2019-02-28 13-11-43

My old neovim build apparently has no Python support for some reason so I cannot easily test myself.

mgedmin commented 5 years ago

My old neovim build apparently has no Python support for some reason so I cannot easily test myself.

Ah, I'd cleaned out my ~/.local/python* and forgot to python3 -m pip install --user pynvim.

I've checked, and the branch coverage is also broken in nvim v0.3.2-1039-gac53536de.

mgedmin commented 5 years ago

Your suggested fix didn't work for me.

I'm currently playing with NVIM v0.4.0-319-g6cd4ff2ab.

mgedmin commented 5 years ago

Your suggested fix didn't work for me.

That would be because I cannot tell a - from a _.

diefans commented 5 years ago

very nice!