modules/output: add source locations to vimPlugin assertions

Include the definition locations of offending vim-plugins in the
`extraPackages` & `extraPackagesAfter` assertion messages.

This makes it easier to track down the plugin declarations,
especially when values originate from multiple modules.
This commit is contained in:
Matt Sturgeon
2026-06-13 22:04:18 +00:00
parent a6554084d7
commit e3c908fdf6
2 changed files with 14 additions and 4 deletions
+13 -3
View File
@@ -31,13 +31,23 @@ let
mkVimPluginPackageAssertion =
opt:
let
vimPlugins = builtins.filter isVimPluginPackage opt.value;
vimPluginDefs = lib.pipe opt.definitionsWithLocations [
# Flatten to [{file, package}]
(lib.concatMap ({ file, value }: map (package: { inherit file package; }) value))
# Select vimPlugins
(lib.filter (def: isVimPluginPackage def.package))
# Group definition files by plugin name
(lib.groupBy (def: lib.getName def.package))
(lib.mapAttrs (_: map (def: def.file)))
];
in
{
assertion = vimPlugins == [ ];
assertion = vimPluginDefs == { };
message = ''
`${opt}` is for executable packages added to Neovim's PATH, but it contains Vim plugin package(s):
${lib.concatMapStringsSep "\n" (package: " - ${lib.getName package}") vimPlugins}
${lib.concatMapAttrsStringSep "\n" (
name: files: " - ${name} defined in ${lib.options.showFiles files}"
) vimPluginDefs}
Use `${options.extraPlugins}` for Vim plugin packages:
${options.extraPlugins} = [ pkgs.vimPlugins.<plugin> ];
+1 -1
View File
@@ -315,7 +315,7 @@
(expect "any" "`extraPackages` is for executable packages added to Neovim's PATH")
(expect "any" "`extraPackagesAfter` is for executable packages added to Neovim's PATH")
(expect "all" "Use `extraPlugins` for Vim plugin packages:")
(expect "all" "nixvim-extra-packages-vim-plugin-test")
(expect "all" "- nixvim-extra-packages-vim-plugin-test defined in `${toString __curPos.file}'")
];
};
};