lib/plugins: take ownership of modules utils

These util functions were previously defined in `modules`, but
`plugins.utils` is a better home.
This commit is contained in:
Matt Sturgeon 2024-12-18 22:12:51 +00:00
parent ec97297fd5
commit 896f6be694
No known key found for this signature in database
GPG key ID: 4F91844CED1A8299
8 changed files with 45 additions and 38 deletions

View file

@ -10,6 +10,9 @@ let
# Removed 2024-09-27
specialArgs = "It has been integrated into `evalNixvim`";
specialArgsWith = "It has been integrated into `evalNixvim`";
# Removed 2024-12-18
applyExtraConfig = "It has been moved to `lib.plugins.utils`";
mkConfigAt = "It has been moved to `lib.plugins.utils`";
};
in
{
@ -45,37 +48,6 @@ in
helpers = self;
} // extraSpecialArgs;
};
/**
Apply an `extraConfig` definition, which should produce a `config` definition.
As used by `mkVimPlugin` and `mkNeovimPlugin`.
The result will be wrapped using a `mkIf` definition.
*/
applyExtraConfig =
{
extraConfig,
cfg,
opts,
enabled ? cfg.enable or (throw "`enabled` argument not provided and no `cfg.enable` option found."),
}:
let
maybeApply = x: maybeFn: if builtins.isFunction maybeFn then maybeFn x else maybeFn;
in
lib.pipe extraConfig [
(maybeApply cfg)
(maybeApply opts)
(lib.mkIf enabled)
];
mkConfigAt =
loc: def:
let
isOrder = loc._type or null == "order";
withOrder = if isOrder then lib.modules.mkOrder loc.priority else lib.id;
loc' = lib.toList (if isOrder then loc.content else loc);
in
lib.setAttrByPath loc' (withOrder def);
}
// lib.mapAttrs (
name: msg: