mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 08:35:43 +02:00
Flake lock file updates: • Updated input 'flake-parts': 'github:hercules-ci/flake-parts/506278e768c2a08bec68eb62932193e341f55c90?narHash=sha256-hgmguH29K2fvs9szpq2r3pz2/8cJd2LPS%2Bb4tfNFCwE%3D' (2024-11-01) → 'github:hercules-ci/flake-parts/205b12d8b7cd4802fbcb8e8ef6a0f1408781a4f9?narHash=sha256-4pDvzqnegAfRkPwO3wmwBhVi/Sye1mzps0zHWYnP88c%3D' (2024-12-04) • Updated input 'git-hooks': 'github:cachix/git-hooks.nix/3308484d1a443fc5bc92012435d79e80458fe43c?narHash=sha256-mnTbjpdqF0luOkou8ZFi2asa1N3AA2CchR/RqCNmsGE%3D' (2024-11-19) → 'github:cachix/git-hooks.nix/6f4e2a2112050951a314d2733a994fbab94864c6?narHash=sha256-SVQVsbafSM1dJ4fpgyBqLZ%2BLft%2BjcQuMtEL3lQWx2Sk%3D' (2024-12-04) • Updated input 'home-manager': 'github:nix-community/home-manager/62d536255879be574ebfe9b87c4ac194febf47c5?narHash=sha256-lYnT%2BEYE47f5yY3KS/Kd4pJ6CO9fhCqumkYYkQ3TK20%3D' (2024-12-01) → 'github:nix-community/home-manager/c7ffc9727d115e433fd884a62dc164b587ff651d?narHash=sha256-zjO6m5BqxXIyjrnUziAzk4%2BT4VleqjstNudSqWcpsHI%3D' (2024-12-07) • Updated input 'nix-darwin': 'github:lnl7/nix-darwin/c6b65d946097baf3915dd51373251de98199280d?narHash=sha256-Qs3YmoLYUJ8g4RkFj2rMrzrP91e4ShAioC9s%2BvG6ENM%3D' (2024-12-02) → 'github:lnl7/nix-darwin/a35b08d09efda83625bef267eb24347b446c80b8?narHash=sha256-sQJAxY1TYWD1UyibN/FnN97paTFuwBw3Vp3DNCyKsMk%3D' (2024-12-07) • Updated input 'nixpkgs': 'github:NixOS/nixpkgs/f9f0d5c5380be0a599b1fb54641fa99af8281539?narHash=sha256-En%2BgSoVJ3iQKPDU1FHrR6zIxSLXKjzKY%2Bpnh9tt%2BYts%3D' (2024-12-02) → 'github:NixOS/nixpkgs/4dc2fc4e62dbf62b84132fe526356fbac7b03541?narHash=sha256-FillH0qdWDt/nlO6ED7h4cmN%2BG9uXwGjwmCnHs0QVYM%3D' (2024-12-05) • Updated input 'nuschtosSearch': 'github:NuschtOS/search/16307548b7a1247291c84ae6a12c0aacb07dfba2?narHash=sha256-BC1CecAQISV5Q4LZK72Gx0%2BfaemOwaChiD9rMVfDPoA%3D' (2024-11-30) → 'github:NuschtOS/search/68e9fad70d95d08156cf10a030bd39487bed8ffe?narHash=sha256-315rJ7O9cOllPDaFscnJhcMleORHbxon0Kq9LAKJ5p4%3D' (2024-12-05) • Updated input 'treefmt-nix': 'github:numtide/treefmt-nix/6209c381904cab55796c5d7350e89681d3b2a8ef?narHash=sha256-2qbdorpq0TXHBWbVXaTqKoikN4bqAtAplTwGuII%2BoAc%3D' (2024-11-29) → 'github:numtide/treefmt-nix/50862ba6a8a0255b87377b9d2d4565e96f29b410?narHash=sha256-qKL3vjO%2BIXFQ0nTinFDqNq/sbbnnS5bMI1y0xX215fU%3D' (2024-12-05)
288 lines
8.2 KiB
Nix
288 lines
8.2 KiB
Nix
{
|
|
lib,
|
|
helpers,
|
|
config,
|
|
pkgs,
|
|
...
|
|
}:
|
|
with lib;
|
|
let
|
|
cfg = config.plugins.coverage;
|
|
|
|
keymapsDef = {
|
|
coverage = {
|
|
command = "";
|
|
description = "Loads a coverage report and immediately displays the coverage signs.";
|
|
};
|
|
load = {
|
|
command = "Load";
|
|
description = "Loads a coverage report but does not display the coverage signs.";
|
|
};
|
|
show = {
|
|
command = "Show";
|
|
description = ''
|
|
Shows the coverage signs.
|
|
Must call `:Coverage` or `:CoverageLoad` first.
|
|
'';
|
|
};
|
|
hide = {
|
|
command = "Hide";
|
|
description = ''
|
|
Hides the coverage signs.
|
|
Must call `:Coverage` or `:CoverageLoad` first.
|
|
'';
|
|
};
|
|
toggle = {
|
|
command = "Toggle";
|
|
description = ''
|
|
Toggles the coverage signs.
|
|
Must call `:Coverage` or `:CoverageLoad` first.
|
|
'';
|
|
};
|
|
clear = {
|
|
command = "Clear";
|
|
description = ''
|
|
Unloads the cached coverage signs.
|
|
`:Coverage` or `:CoverageLoad` must be called again to relad the data.
|
|
'';
|
|
};
|
|
summary = {
|
|
command = "Summary";
|
|
description = "Displays a coverage summary report in a floating window.";
|
|
};
|
|
loadLcov = {
|
|
command = "LoadLcov";
|
|
description = ''
|
|
Loads a coverage report from an lcov file but does not display the coverage signs.
|
|
Uses the lcov file configuration option.
|
|
'';
|
|
};
|
|
};
|
|
in
|
|
{
|
|
options.plugins.coverage = helpers.neovim-plugin.extraOptionsOptions // {
|
|
enable = mkEnableOption "nvim-coverage";
|
|
|
|
package = lib.mkPackageOption pkgs "nvim-coverage" {
|
|
default = [
|
|
"vimPlugins"
|
|
"nvim-coverage"
|
|
];
|
|
};
|
|
|
|
keymapsSilent = mkOption {
|
|
type = types.bool;
|
|
description = "Whether nvim-coverage keymaps should be silent";
|
|
default = false;
|
|
};
|
|
|
|
keymaps = mapAttrs (
|
|
optionName: properties: helpers.mkNullOrOption types.str properties.description
|
|
) keymapsDef;
|
|
|
|
autoReload = helpers.defaultNullOpts.mkBool false ''
|
|
If true, the `coverage_file` for a language will be watched for changes after executing
|
|
`:CoverageLoad` or `coverage.load()`.
|
|
The file watcher will be stopped after executing `:CoverageClear` or `coverage.clear()`.
|
|
'';
|
|
|
|
autoReloadTimeoutMs = helpers.defaultNullOpts.mkInt 500 ''
|
|
The number of milliseconds to wait before auto-reloading coverage after detecting a change.
|
|
'';
|
|
|
|
commands = helpers.defaultNullOpts.mkBool true "If true, create commands.";
|
|
|
|
highlights = {
|
|
covered = helpers.defaultNullOpts.mkAttributeSet {
|
|
fg = "#B7F071";
|
|
} "Highlight group for covered signs.";
|
|
|
|
uncovered = helpers.defaultNullOpts.mkAttributeSet {
|
|
fg = "#F07178";
|
|
} "Highlight group for uncovered signs.";
|
|
|
|
partial = helpers.defaultNullOpts.mkAttributeSet {
|
|
fg = "#AA71F0";
|
|
} "Highlight group for partial coverage signs.";
|
|
|
|
summaryBorder = helpers.defaultNullOpts.mkAttributeSet {
|
|
link = "FloatBorder";
|
|
} "Border highlight group of the summary pop-up.";
|
|
|
|
summaryNormal = helpers.defaultNullOpts.mkAttributeSet {
|
|
link = "NormalFloat";
|
|
} "Normal text highlight group of the summary pop-up.";
|
|
|
|
summaryCursorLine = helpers.defaultNullOpts.mkAttributeSet {
|
|
link = "CursorLine";
|
|
} "Cursor line highlight group of the summary pop-up.";
|
|
|
|
summaryHeader = helpers.defaultNullOpts.mkAttributeSet {
|
|
style = "bold,underline";
|
|
sp = "bg";
|
|
} "Header text highlight group of the summary pop-up.";
|
|
|
|
summaryPass = helpers.defaultNullOpts.mkAttributeSet {
|
|
link = "CoverageCovered";
|
|
} "Pass text highlight group of the summary pop-up.";
|
|
|
|
summaryFail = helpers.defaultNullOpts.mkAttributeSet {
|
|
link = "CoverageUncovered";
|
|
} "Fail text highlight group of the summary pop-up.";
|
|
};
|
|
|
|
loadCoverageCb = helpers.defaultNullOpts.mkLuaFn' {
|
|
description = "A lua function that will be called when a coverage file is loaded.";
|
|
pluginDefault = "nil";
|
|
example = ''
|
|
function(ftype)
|
|
vim.notify("Loaded " .. ftype .. " coverage")
|
|
end
|
|
'';
|
|
};
|
|
|
|
signs =
|
|
mapAttrs
|
|
(
|
|
optionName:
|
|
{
|
|
prettyName ? optionName,
|
|
defaults,
|
|
}:
|
|
{
|
|
hl = helpers.defaultNullOpts.mkStr defaults.hl "The highlight group used for ${prettyName} signs.";
|
|
|
|
text = helpers.defaultNullOpts.mkStr defaults.text "The text used for ${prettyName} signs.";
|
|
}
|
|
)
|
|
{
|
|
covered = {
|
|
defaults = {
|
|
hl = "CoverageCovered";
|
|
text = "▎";
|
|
};
|
|
};
|
|
uncovered = {
|
|
defaults = {
|
|
hl = "CoverageUncovered";
|
|
text = "▎";
|
|
};
|
|
};
|
|
partial = {
|
|
prettyName = "partial coverage";
|
|
defaults = {
|
|
hl = "CoveragePartial";
|
|
text = "▎";
|
|
};
|
|
};
|
|
};
|
|
|
|
signGroup = helpers.defaultNullOpts.mkStr "coverage" ''
|
|
Name of the sign group used when placing the signs.
|
|
See `:h sign-group`.
|
|
'';
|
|
|
|
summary = {
|
|
widthPercentage =
|
|
helpers.defaultNullOpts.mkNullable (types.numbers.between 0.0 1.0) 0.7
|
|
"Width of the pop-up window.";
|
|
|
|
heightPercentage =
|
|
helpers.defaultNullOpts.mkNullable (types.numbers.between 0.0 1.0) 0.5
|
|
"Height of the pop-up window.";
|
|
|
|
borders = mapAttrs (optionName: default: helpers.defaultNullOpts.mkStr default "") {
|
|
topleft = "╭";
|
|
topright = "╮";
|
|
top = "─";
|
|
left = "│";
|
|
right = "│";
|
|
botleft = "╰";
|
|
botright = "╯";
|
|
bot = "─";
|
|
highlight = "Normal:CoverageSummaryBorder";
|
|
};
|
|
|
|
minCoverage = helpers.defaultNullOpts.mkNullable (types.numbers.between 0 100) 80 ''
|
|
Minimum coverage percentage.
|
|
Values below this are highlighted with the fail group, values above are highlighted with
|
|
the pass group.
|
|
'';
|
|
};
|
|
|
|
lang = helpers.defaultNullOpts.mkAttributeSet' {
|
|
description = ''
|
|
Each key corresponds with the `filetype` of the language and maps to an attrs of
|
|
configuration values that differ.
|
|
|
|
See plugin documentation for language specific options.
|
|
'';
|
|
|
|
example = {
|
|
python = {
|
|
coverage_file = ".coverage";
|
|
coverage_command = "coverage json --fail-under=0 -q -o -";
|
|
};
|
|
ruby = {
|
|
coverage_file = "coverage/coverage.json";
|
|
};
|
|
};
|
|
};
|
|
|
|
lcovFile = helpers.mkNullOrOption types.str "File that the plugin will try to read lcov coverage from.";
|
|
};
|
|
|
|
config =
|
|
let
|
|
setupOptions =
|
|
with cfg;
|
|
{
|
|
auto_reload = autoReload;
|
|
auto_reload_timeout_ms = autoReloadTimeoutMs;
|
|
inherit commands;
|
|
highlights = with highlights; {
|
|
inherit covered uncovered partial;
|
|
summary_border = summaryBorder;
|
|
summary_normal = summaryNormal;
|
|
summary_cursor_line = summaryCursorLine;
|
|
summary_header = summaryHeader;
|
|
summary_pass = summaryPass;
|
|
summary_fail = summaryFail;
|
|
};
|
|
load_coverage_cb = loadCoverageCb;
|
|
inherit signs;
|
|
sign_group = signGroup;
|
|
summary = with summary; {
|
|
width_percentage = widthPercentage;
|
|
height_percentage = heightPercentage;
|
|
inherit borders;
|
|
min_coverage = minCoverage;
|
|
};
|
|
inherit lang;
|
|
lcov_file = lcovFile;
|
|
}
|
|
// cfg.extraOptions;
|
|
in
|
|
mkIf cfg.enable {
|
|
extraPlugins = [ cfg.package ];
|
|
|
|
extraConfigLua = ''
|
|
require("coverage").setup(${helpers.toLuaObject setupOptions})
|
|
'';
|
|
|
|
keymaps = flatten (
|
|
mapAttrsToList (
|
|
optionName: properties:
|
|
let
|
|
key = cfg.keymaps.${optionName};
|
|
in
|
|
optional (key != null) {
|
|
mode = "n";
|
|
inherit key;
|
|
action = ":Coverage${properties.command}<CR>";
|
|
options.silent = cfg.keymapsSilent;
|
|
}
|
|
) keymapsDef
|
|
);
|
|
};
|
|
}
|