mirror of
https://github.com/NotAShelf/nvf.git
synced 2026-06-24 05:23:26 +00:00
wrapper/lazy: allow conditionally calling setup() for plugins
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I644a46924f6a7fbb46e507d2599f03b06a6a6964
This commit is contained in:
parent
fc0ec55fc1
commit
bf7fd28d79
2 changed files with 60 additions and 18 deletions
|
|
@ -29,7 +29,7 @@
|
|||
then spec.package.pname
|
||||
else spec.package.name;
|
||||
in
|
||||
(removeAttrs spec ["package" "setupModule" "setupOpts" "keys"])
|
||||
(removeAttrs spec ["package" "setupModule" "setupOpts" "setupCond" "keys"])
|
||||
// {
|
||||
"@1" =
|
||||
if spec.package != null && packageName != name && spec.load == null
|
||||
|
|
@ -73,14 +73,20 @@
|
|||
after =
|
||||
if spec.setupModule == null && spec.after == null
|
||||
then null
|
||||
else
|
||||
else let
|
||||
setupCall = "require(${toJSON spec.setupModule}).setup(${toLuaObject spec.setupOpts})";
|
||||
conditionalSetup =
|
||||
if spec.setupCond != null
|
||||
then ''
|
||||
if (${spec.setupCond}) then
|
||||
${setupCall}
|
||||
end''
|
||||
else setupCall;
|
||||
in
|
||||
mkLuaInline ''
|
||||
function()
|
||||
${optionalString (spec.beforeSetup != null) spec.beforeSetup}
|
||||
${
|
||||
optionalString (spec.setupModule != null)
|
||||
"require(${toJSON spec.setupModule}).setup(${toLuaObject spec.setupOpts})"
|
||||
}
|
||||
${optionalString (spec.setupModule != null) conditionalSetup}
|
||||
${optionalString (spec.after != null) spec.after}
|
||||
end
|
||||
'';
|
||||
|
|
@ -105,11 +111,19 @@
|
|||
|
||||
pluginPackages = filter (x: x != null) (mapAttrsToList (_: plugin: plugin.package) cfg.plugins);
|
||||
|
||||
specToNotLazyConfig = _: spec: ''
|
||||
specToNotLazyConfig = _: spec: let
|
||||
setupCall = "require(${toJSON spec.setupModule}).setup(${toLuaObject spec.setupOpts})";
|
||||
conditionalSetup =
|
||||
if spec.setupCond != null
|
||||
then ''
|
||||
if (${spec.setupCond}) then
|
||||
${setupCall}
|
||||
end''
|
||||
else setupCall;
|
||||
in ''
|
||||
do
|
||||
${optionalString (spec.before != null) spec.before}
|
||||
${optionalString (spec.setupModule != null)
|
||||
"require(${toJSON spec.setupModule}).setup(${toLuaObject spec.setupOpts})"}
|
||||
${optionalString (spec.setupModule != null) conditionalSetup}
|
||||
${optionalString (spec.after != null) spec.after}
|
||||
end
|
||||
'';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue