mirror of
https://github.com/nix-community/nixvim.git
synced 2026-08-24 10:14:03 -05:00
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:
+13
-3
@@ -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> ];
|
||||
|
||||
@@ -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}'")
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user