{ lib, config, ... }: let cfg = config.presets.base.coverage; in { options.presets.base.coverage = { enable = lib.mkEnableOption "coverage"; }; config = lib.mkIf cfg.enable { keymaps = [ { key = "cs"; action = # vim ":CoverageSummary"; } { key = "cr"; action = # vim ":CoverageClear:CoverageLoad:CoverageShow"; } { key = "ch"; action = # vim ":CoverageHide"; } { key = "cc"; action = # vim ":CoverageShow"; } ]; autoCmd = [ { event = [ "BufEnter" ]; callback.__raw = # lua '' function() local ftype = vim.bo.filetype local ok, lang = pcall(require, "coverage.languages." .. ftype) if not ok then return end local config = require("coverage.config") local util = require("coverage.util") local Path = require("plenary.path") local ft_config = config.opts.lang[ftype] if ft_config == nil then return end local p = Path:new(util.get_coverage_file(ft_config.coverage_file)) if not p:exists() then return end require("coverage").load(true) end ''; } ]; plugins = { coverage = { enable = true; autoReload = true; }; which-key.settings.spec = [ { __unkeyed-1 = "c"; desc = "Coverage"; icon = "󰠞"; } { __unkeyed-1 = "cs"; desc = "Summary"; icon = ""; } { __unkeyed-1 = "cr"; desc = "Reload"; icon = "󰑓"; } { __unkeyed-1 = "ch"; desc = "Hide"; icon = "󱨃"; } { __unkeyed-1 = "cc"; desc = "Show"; icon = "󱨂"; } ]; }; }; }