GithubHelp home page GithubHelp logo

dsych / blanket.nvim Goto Github PK

View Code? Open in Web Editor NEW
30.0 1.0 2.0 160 KB

Code coverage gutter for Neovim based on Jacoco reports

License: MIT License

Lua 100.00%
coverage-report neovim-plugin java coverage-gutters jacocoverage

blanket.nvim's Introduction

BLANKET.NVIM ๐Ÿ›Œ๐Ÿป

Designed to induce that warm and fuzzy feeling of knowing that your code is covered

Overview

This plugin provides a code coverage gutter in Neovim based on the Jacoco reports for Java projects.

Features

  • Displaying uncoverted, covered and partially 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

example with all 3 types of signs

Configurations

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

Available functions

  • :lua require'blanket'.start() - start the plugin, useful when filetype 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 when filetype property is not set
  • :lua require'blanket'.pick_report_path() - pick a new report_path and refresh the report
  • :lua require'blanket'.set_report_path(<new_file_path>) - change report_path to a new value and refresh the gutter based on the new report

Troubleshooting

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:

  1. Generate coverage report for a simple app with maven
  2. 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 the report_path to suite your needs and open the file of your liking.

Credits

  • xml2lua - xml parsing library used to read Jacoco report (found under lua/internal/*)
  • jacoco-parse - inspiration for algorithm to interpret Jacoco report content

blanket.nvim's People

Contributors

dsych avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

blanket.nvim's Issues

Color for covered lines is off

Hi,

i noticed that you set the color of covered lines to "statement", but depending on the themes used it won't be green. Maybe provide a custom highlight group here, so people are free to adjust the color.

Regards

Consider using different parsing method?

Hi,

this is quite a big one: have you considered using a different parsing algorithm? This plugin is sadly unusable with larger codebases.

It'd be way more efficient to let jacoco generate the html coverage pages and parse them instead of the whole coverage file.

Thoughts?

Regards

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.