Devel::Cover::Report::Nvim(3pm)

NAME
Devel::Cover::Report::Nvim - Backend for displaying coverage data in Neovim

VERSION
version 1.51

SYNOPSIS
 cover -report nvim

DESCRIPTION
This module provides a reporting mechanism for displaying coverage data in Neovim using Lua. It is designed to be called from the "cover" program.

By default, the output of this report is a file named "coverage.lua" in the directory of the coverage database. To use it, run

 :luafile cover_db/coverage.lua

and you should see signs in the left column indicating the coverage status of that line.

The signs are as follows:

 P - Pod coverage
 S - Statement coverage
 R - Subroutine coverage
 B - Branch coverage
 C - Condition coverage

The last of the criteria, in the order given above, is the one which is displayed. Correctly covered criteria are shown in green. Incorrectly covered criteria are shown in red. Any incorrectly covered criterion will override a correctly covered criterion.

If the coverage for the file being displayed is out of date the function called coverage_old() is called and passed the name of the file. Similarly, for current coverage data file coverage_valid() is called.

Colors and signs can be customized using global vim variables. Set these in your init.lua or init.vim file before loading the coverage script.

Available configuration variables:

 vim.g.devel_cover_fg         -- Foreground color for covered lines (default: "Green")
 vim.g.devel_cover_error_fg   -- Foreground color for uncovered lines (default: "Red")
 vim.g.devel_cover_bg         -- Background color for covered lines (default: nil)
 vim.g.devel_cover_error_bg   -- Background color for uncovered lines (default: nil)
 vim.g.devel_cover_valid_bg   -- Background when coverage is current (default: nil)
 vim.g.devel_cover_old_bg     -- Background when coverage is old (default: nil)
 vim.g.devel_cover_cterm      -- Terminal styling (default: "bold")
 vim.g.devel_cover_gui        -- GUI styling (default: "bold")
 vim.g.devel_cover_linehl     -- Line highlight group for covered (default: "cov")
 vim.g.devel_cover_linehl_error -- Line highlight group for errors (default: "err")
 vim.g.devel_cover_signs      -- Custom sign text table
 vim.g.devel_cover_sign_group -- Sign group name for dedicated column (default: "DevelCover")
 vim.g.devel_cover_sign_priority -- Sign priority within group (default: 10)

Example configuration for solarized theme in init.lua:

 -- Set colors before loading coverage
 vim.g.devel_cover_fg = "#859900"        -- solarized green
 vim.g.devel_cover_error_fg = "#dc322f"  -- solarized red
 vim.g.devel_cover_valid_bg = "#073642"  -- solarized base02
 vim.g.devel_cover_old_bg = "#342a2a"    -- darker red-tinted background
 vim.g.devel_cover_cterm = "NONE"
 vim.g.devel_cover_gui = "NONE"

 -- Custom sign characters (optional)
 -- Note: The same character is used for both covered/uncovered
 -- The difference is shown through fg/bg colors defined above
 vim.g.devel_cover_signs = {
   pod = "P ",
   subroutine = "R ",
   statement = "· ",  -- Subtle dot for statements (most common)
   branch = "B ",
   condition = "C "
 }

 -- Or for a minimal look that relies purely on colors
 vim.g.devel_cover_bg = "#002b36"        -- dark for covered
 vim.g.devel_cover_error_bg = "#2d1616"  -- dark red for uncovered
 vim.g.devel_cover_signs = {
   pod = "  ",
   subroutine = "  ",
   statement = "│ ",  -- Thin vertical bar (unobtrusive)
   branch = "  ",
   condition = "  "
 }

 -- Or use subtle Unicode characters
 vim.g.devel_cover_signs = {
   pod = "¶ ",
   subroutine = "ƒ ",
   statement = "• ",  -- Small bullet (unobtrusive)
   branch = "» ",
   condition = "? "
 }

 -- For a dedicated coverage column (recommended)
 -- This keeps coverage signs separate from other signs like diagnostics
 vim.g.devel_cover_sign_group = "DevelCover"  -- Creates its own column

 -- You can also configure the sign column appearance
 vim.o.signcolumn = "yes:2"  -- Show 2 sign columns (1 for diagnostics, 1 for coverage)

Alternative: You can still override via devel-cover.lua in your config directory for more complex customizations

This configuration sets the background colour of the signs to a dark red when the coverage data is out of date.

coverage.lua adds two user commands: :Cov and :Uncov which can be used to toggle the state of coverage signs.

The idea and the lua template is adapted from the Vim version which was shamelessly stolen from Simplecov-Vim. See https://github.com/nyarly/Simplecov-Vim

SEE ALSO
 Devel::Cover
 Devel::Cover::Report::Vim
 Simplecov-Vim (https://github.com/nyarly/Simplecov-Vim)

BUGS
Huh?

LICENCE
Copyright 2012-2025, Paul Johnson (paul@pjcj.net)

This software is free. It is licensed under the same terms as Perl itself.

The latest version of this software should be available from my homepage: https://pjcj.net

The template is adapted from the Vim version which was copied from Simplecov-Vim (https://github.com/nyarly/Simplecov-Vim) and is under the MIT Licence.

The MIT License

Copyright (c) 2011 Judson Lester

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

POD ERRORS
Hey! The above document had some coding errors, which are explained below:

Around line 544:
    Non-ASCII character seen before =encoding in '"·'. Assuming UTF-8