lazy: refactor common var

This commit is contained in:
Ching Pei Yang 2024-10-28 02:26:56 +01:00
parent aac776f7a4
commit 12ed05bcfb
No known key found for this signature in database
GPG key ID: B3841364253DC4C8

View file

@ -58,6 +58,8 @@
}; };
lznSpecs = mapAttrsToList toLuaLznSpec cfg.plugins; lznSpecs = mapAttrsToList toLuaLznSpec cfg.plugins;
pluginPackages = mapAttrsToList (_: plugin: plugin.package) cfg.plugins;
specToNotLazyConfig = _: spec: '' specToNotLazyConfig = _: spec: ''
do do
${optionalString (spec.before != null) spec.before} ${optionalString (spec.before != null) spec.before}
@ -80,7 +82,7 @@ in {
(mkIf cfg.enable { (mkIf cfg.enable {
startPlugins = ["lz-n" "lzn-auto-require"]; startPlugins = ["lz-n" "lzn-auto-require"];
optPlugins = mapAttrsToList (_: plugin: plugin.package) cfg.plugins; optPlugins = pluginPackages;
luaConfigRC.lzn-load = entryBefore ["pluginConfigs"] '' luaConfigRC.lzn-load = entryBefore ["pluginConfigs"] ''
require('lz.n').load(${toLuaObject lznSpecs}) require('lz.n').load(${toLuaObject lznSpecs})
@ -88,7 +90,7 @@ in {
}) })
(mkIf (!cfg.enable) { (mkIf (!cfg.enable) {
startPlugins = mapAttrsToList (_: plugin: plugin.package) cfg.plugins; startPlugins = pluginPackages;
luaConfigPre = luaConfigPre =
concatStringsSep "\n" concatStringsSep "\n"
(filter (x: x != null) (mapAttrsToList (_: spec: spec.beforeAll) cfg.plugins)); (filter (x: x != null) (mapAttrsToList (_: spec: spec.beforeAll) cfg.plugins));