Designed to induce that warm and fuzzy feeling of knowing that your code is covered
This plugin provides a code coverage gutter in Neovim based on the Jacoco reports for Java projects.
- Displaying
uncoverted
,covered
andpartially covered
(not all code branches are executed) lines - Watch report for changes and refresh the coverage gutter
- Autocomands to fire when specific file type is opened
Only report_path
is required, everything else is optional.
lua << EOF
require'blanket'.setup{
-- can use env variables and anything that could be interpreted by expand(), see :h expandcmd()
-- OPTIONAL
report_path = vim.fn.getcwd().."/target/site/jacoco/jacoco.xml",
-- refresh gutter every time we enter java file
-- defauls to empty - no autocmd is created
filetypes = "java",
-- for debugging purposes to see whether current file is present inside the report
-- defaults to false
silent = true,
-- can set the signs as well
signs = {
priority = 10,
incomplete_branch = "█",
uncovered = "█",
covered = "█",
sign_group = "Blanket"
-- and the highlights for each sign!
-- useful for themes where below highlights are similar
incomplete_branch_color = "WarningMsg",
covered_color = "Statement",
uncovered_color = "Error",
},
}
EOF
:lua require'blanket'.start()
- start the plugin, useful whenfiletype
property is not set:lua require'blanket'.stop()
- stop displaying coverage and cleanup autocmds, watcher etc.:lua require'blanket'.refresh()
- manually trigger a refresh of signs, useful whenfiletype
property is not set:lua require'blanket'.pick_report_path()
- pick a newreport_path
and refresh the report:lua require'blanket'.set_report_path(<new_file_path>)
- changereport_path
to a new value and refresh the gutter based on the new report
Before opening an issue, make sure to reproduce you problem with the minimal config from examples/minimal.lua
.
Run the following command from inside the plugin directory and record the error message:
mvn -f ./examples/jacoco/pom.xml clean test && nvim --noplugin -u NONE -u ./examples/minimal.lua ./examples/jacoco/src/main/java/com/example/jacoco/MessageBuilder.java
The above will:
- Generate coverage report for a simple app with maven
- Launch vim with only
blanket.nvim
configured to look for report generated in the previous step
Alternatively, you can also just download the
minimal.lua
config, update thereport_path
to suite your needs and open the file of your liking.
- xml2lua - xml parsing library used to read Jacoco report (found under
lua/internal/*
) - jacoco-parse - inspiration for algorithm to interpret Jacoco report content