Code Monkey home page Code Monkey logo

nvim-coverage's Introduction

nvim-coverage

Displays coverage information in the sign column.

markers

Displays a coverage summary report in a pop-up window.

summary

Currently supports:

Note: This plugin does not run tests. It justs loads/displays a coverage report generated by a test suite. To run tests from neovim with coverage enabled, try one of these plugins:

Installation

This plugin depends on plenary.

Plug 'nvim-lua/plenary.nvim'
Plug 'andythigpen/nvim-coverage'

The following lua is required to configure the plugin after installation.

require("coverage").setup()

Configuration

See docs for more info.

Example:

require("coverage").setup({
	commands = true, -- create commands
	highlights = {
		-- customize highlight groups created by the plugin
		covered = { fg = "#C3E88D" },   -- supports style, fg, bg, sp (see :h highlight-gui)
		uncovered = { fg = "#F07178" },
	},
	signs = {
		-- use your own highlight groups or text markers
		covered = { hl = "CoverageCovered", text = "" },
		uncovered = { hl = "CoverageUncovered", text = "" },
	},
	summary = {
		-- customize the summary pop-up
		min_coverage = 80.0,      -- minimum coverage threshold (used for highlighting)
	},
	lang = {
		-- customize language specific settings
	},
})

Extending to other languages

  1. Create a new lua module matching the pattern coverage.languages.<filetype> where <filetype> matches the vim filetype for the coverage language (ex. python).
  2. Implement the required methods listed below.

Required methods:

local M = {}

--- Loads a coverage report.
-- This method should perform whatever steps are necessary to generate a coverage report.
-- The coverage report results should passed to the callback, which will be cached by the plugin.
-- @param callback called with results of the coverage report
M.load = function(callback)
  -- TODO: callback(results)
end

--- Returns a list of signs that will be placed in buffers.
-- This method should use the coverage data (previously generated via the load method) to 
-- return a list of signs.
-- @return list of signs
M.sign_list = function(data)
  -- TODO: generate a list of signs using:
  -- require("coverage.signs").new_covered(bufnr, linenr)
  -- require("coverage.signs").new_uncovered(bufnr, linenr)
end

--- Returns a summary report.
-- @return summary report
M.summary = function(data)
  -- TODO: generate a summary report in the format
  return {
    files = {
      { -- all fields, except filename, are optional - the report will be blank if the field is nil
        filename = fname,            -- filename displayed in the report
        statements = statements,     -- number of total statements in the file
        missing = missing,           -- number of lines missing coverage (uncovered) in the file
        excluded = excluded,         -- number of lines excluded from coverage reporting in the file
        branches = branches,         -- number of total branches in the file
        partial = partial_branches,  -- number of branches that are partially covered in the file
        coverage = coverage,         -- coverage percentage (float) for this file
      }
    },
    totals = { -- optional
      statements = total_statements,     -- number of total statements in the report
      missing = total_missing,           -- number of lines missing coverage (uncovered) in the report
      excluded = total_excluded,         -- number of lines excluded from coverage reporting in the report
      branches = total_branches,         -- number of total branches in the report
      partial = total_partial_branches,  -- number of branches that are partially covered in the report
      coverage = total_coverage,         -- coverage percentage to display in the report
    }
  }
end

return M

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.