mr-u0b0dy/crazy-coverage.nvim

github github
test
stars 13
issues 3
subscribers 0
forks 3
CREATED

UPDATED


crazy-coverage.nvim

A Neovim plugin for displaying code coverage overlays directly in your editor with smart auto-loading and file watching.

Features

  • Multi-Format Support: LCOV, LLVM JSON, Cobertura XML, Go Coverprofile, GCOV, LLVM Profdata
  • Smart Toggle: Single command auto-loads coverage and watches for changes
  • Flexible Display: Show hit counts via virtual text or sign column
  • Branch/Region Overlays: Inspect branch and LLVM region hit details at cursor
  • Tree Integration: Coverage in NvimTree and neo-tree (optional)
  • Configurable: Customize colors, display behavior, and summary popup
  • Navigation: Jump between covered/uncovered/partial lines

Demo

Branch Coverage Overlay

Branch Coverage Overlay

Coverage Summary

Coverage Summary

Region Coverage Overlay

Region Coverage Overlay

Supported Languages

  • C/C++ - GCC (gcov/lcov), LLVM/Clang
  • Go - Native go test -coverprofile (coverage.out)
  • Any Language - Via LCOV, Cobertura XML, or LLVM JSON formats

The plugin supports any language that can generate coverage in one of the supported formats.

Installation

Using lazy.nvim

{
  "mr-u0b0dy/crazy-coverage.nvim",
  config = function()
    require("crazy-coverage").setup()
  end,
}

Using packer.nvim

use {
  "mr-u0b0dy/crazy-coverage.nvim",
  config = function()
    require("crazy-coverage").setup()
  end,
}

See Installation Guide for other plugin managers and AstroVim setup.

Quick Start

-- Toggle coverage (auto-loads file, watches for changes)
:CoverageToggle

-- Navigate uncovered code
]cu  " Next uncovered line
[cu  " Previous uncovered line

What the toggle does:

  • Finds and loads coverage file automatically
  • Enables overlay with line highlighting
  • Watches file for changes (auto-reloads)
  • Shows notifications on updates
  • Cleans up everything when disabled

Automatic Coverage File Discovery

The plugin intelligently finds your coverage file automatically. It:

  1. Searches Standard Directories in order:

    • build/coverage/ - CMake build output
    • coverage/ - Standard coverage directory
    • build/ - Build directory root
    • . - Project root
  2. Detects by Content - Not just filenames:

    • Finds LCOV files (even if not named *.lcov)
    • Finds JSON coverage reports (even with custom names)
    • Finds Cobertura XML files (regardless of filename)
    • Finds Go coverprofile files (coverage.out)
    • Finds GCOV/LLVM Profdata binary files
  3. Supports Any Filename:

    ✓ build/coverage_report              (no extension)
    ✓ coverage_2025_01_09.json           (custom name)
    ✓ results.xml                        (non-standard name)
    ✓ my_coverage_data                   (any name works)
    

You can customize the search directories in config:

require("crazy-coverage").setup({
  coverage_dirs = {
    "build/coverage",      -- Search here first
    ".coverage",           -- Custom location
    "coverage",
    ".",
  }
})

See Configuration Reference for more details.

Configuration

Basic Setup

require("crazy-coverage").setup({
  hit_count = {
    show_by_default = true,        -- Show hit counts when coverage is enabled
    display = "eol",              -- "eol", "inline", "overlay", "right_align", "sign"
  },
  auto_adapt_colors = true,       -- Auto-adapt colors to your theme
})

Common Configurations

-- Right-aligned with branch coverage
require("crazy-coverage").setup({
  hit_count = {
    display = "right_align",
  },
  show_branch_summary = true,      -- Branch overlay header: taken/total + percentage
})

-- Custom colors (disable auto-adaptation)
require("crazy-coverage").setup({
  auto_adapt_colors = false,
  colors = {
    covered = { bg = "#1a4d1a", fg = "#66ff66" },
    uncovered = { bg = "#4d1a1a", fg = "#ff6666" },
    partial = { bg = "#4d4d1a", fg = "#ffff66" },
  },
})

-- Auto-adapt with one manual override
require("crazy-coverage").setup({
  auto_adapt_colors = true,  -- Adapt most colors
  colors = {
    uncovered = "#660000",   -- But always use dark red for uncovered
  },
})

Legacy options (default_show_hit_count, show_hit_count) are still supported for compatibility.

See Configuration Reference for all 15+ options.

Commands

Command Description
:CoverageToggle Toggle coverage overlay (auto-loads, watches file)
:CoverageToggleHitCount Toggle hit count display
:CoverageToggleBranchOverlay Toggle branch overlay at cursor
:CoverageToggleRegionOverlay Toggle LLVM region overlay at cursor
:CoverageToggleNvimTree Toggle coverage display in NvimTree
:CoverageToggleNeoTree Toggle coverage display in neo-tree
:CoverageLoad <file> Manually load specific coverage file
:CoverageSummary <project/file> Show coverage summary popup (alias: :CrazyCoverageSummary)
:CoverageNextCovered Jump to next covered line
:CoveragePrevCovered Jump to previous covered line
:CoverageNextUncovered Jump to next uncovered line
:CoveragePrevUncovered Jump to previous uncovered line
:CoverageNextPartial Jump to next partially covered line
:CoveragePrevPartial Jump to previous partially covered line

See Usage Guide for keybindings and navigation.

Documentation

Requirements

  • Neovim 0.7+
  • Coverage files from your build system (lcov, llvm-cov, etc.)

License

Apache License 2.0 - Copyright © 2026 mr-u0b0dy

Contributing

See Development Guide for testing and contribution guidelines.