mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-12-16 00:51:03 +00:00
lazy: add assertions for common pitfalls
This commit is contained in:
parent
c4ba376478
commit
cf906180ae
1 changed files with 29 additions and 3 deletions
|
|
@ -3,7 +3,7 @@
|
||||||
config,
|
config,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (builtins) toJSON typeOf head length filter concatLists concatStringsSep;
|
inherit (builtins) toJSON typeOf head length filter concatLists concatStringsSep tryEval;
|
||||||
inherit (lib.attrsets) mapAttrsToList;
|
inherit (lib.attrsets) mapAttrsToList;
|
||||||
inherit (lib.modules) mkIf mkMerge;
|
inherit (lib.modules) mkIf mkMerge;
|
||||||
inherit (lib.generators) mkLuaInline;
|
inherit (lib.generators) mkLuaInline;
|
||||||
|
|
@ -21,10 +21,36 @@
|
||||||
else keySpec.action;
|
else keySpec.action;
|
||||||
};
|
};
|
||||||
|
|
||||||
toLuaLznSpec = name: spec:
|
toLuaLznSpec = name: spec: let
|
||||||
|
packageName =
|
||||||
|
if typeOf spec.package == "string"
|
||||||
|
then spec.package
|
||||||
|
else if (spec.package ? pname && (tryEval spec.package.pname).success)
|
||||||
|
then spec.package.pname
|
||||||
|
else spec.package.name;
|
||||||
|
in
|
||||||
(removeAttrs spec ["package" "setupModule" "setupOpts" "keys"])
|
(removeAttrs spec ["package" "setupModule" "setupOpts" "keys"])
|
||||||
// {
|
// {
|
||||||
"@1" = name;
|
"@1" =
|
||||||
|
if spec.package != null && packageName != name && spec.load == null
|
||||||
|
then
|
||||||
|
abort ''
|
||||||
|
vim.lazy.plugins.${name} does not match the package name ${packageName}.
|
||||||
|
|
||||||
|
Please either:
|
||||||
|
- rename it to vim.lazy.plugins.${packageName}, or
|
||||||
|
- if you intend to use a custom loader, specify a
|
||||||
|
vim.lazy.plugins.${name}.load function.
|
||||||
|
''
|
||||||
|
else if spec.package == null && spec.load == null
|
||||||
|
then
|
||||||
|
abort ''
|
||||||
|
vim.lazy.plugins.${name} has null package but no load function given.
|
||||||
|
|
||||||
|
Please either specify a package, or (if you know what you're doing) provide a
|
||||||
|
custom load function.
|
||||||
|
''
|
||||||
|
else name;
|
||||||
beforeAll =
|
beforeAll =
|
||||||
if spec.beforeAll != null
|
if spec.beforeAll != null
|
||||||
then
|
then
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue