mgedmin / coverage-highlight.vim

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

Automatic coverage reloading #32

Open azmeuk opened 1 year ago

azmeuk commented 1 year ago

This might be related to #26. This would be awesome if coverage was automagically reloaded in vim when the .coverage file is updated.

What do you think?

mgedmin commented 1 year ago

That sounds like a neat idea!

I have no idea how to implement it.

For my personal convenience I have hooked into asyncrun.vim to do a :HighlightCoverageForAll whenever I run a command like make coverage or tox -e coverage, among other things: https://github.com/mgedmin/dotvim/blob/78fe377d5f54e3b590f76bc74330443fb6ccf13a/vimrc#L909-L943

This does mean that I have less incentives to search for a better generic solution ;)

tshirtman commented 9 months ago

If we can have a long running python process, depending on watchdog or something like it to directly detect changes to coverage files should work.

Alternatively, I think hooking on FocusGained and BufEnter would be a good start, checking if coverage is currently active, and if so, check if the coverage file was modified recently enough, and reload it.