You need to run the coverage measurement from the plugin itself, i.e. like this:
# Start measuring coverage if in testing
if vim.vars.get('measure_coverage'):
import os
import atexit
import coverage
coverage_path = os.path.expanduser('~/coverage-data/.coverage.{0}'.format(os.getpid()))
cov = coverage.coverage(data_file=coverage_path)
cov.start()
def save_coverage():
cov.stop()
cov.save()
atexit.register(save_coverage)
If the plugin was invoked multiple times, you will need to combine the coverage files, using the coverage tool:
$ cd ~/coverage-data
$ coverage combine
This will generate combined .coverage file, which can be then used to generate the desired report.
Note: Make sure you're executing the measurement part only once per vim instance, otherwise the coverage file might get rewritten. In such case, another source of uniqueness (i.e. random number) other than PID should be used to generate the name of the .coverage file.