lib/modules: add applyExtraConfig
Used for - mkVimPlugin: extraConfig - mkNeovimPlugin: extraConfig - mkLsp: extraConfig - mkLsp: settings - mkExtension (telecsope): extraConfig
This commit is contained in:
parent
c7b7b6481b
commit
63cfc84abe
6 changed files with 69 additions and 14 deletions
|
|
@ -36,6 +36,28 @@ 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)
|
||||
];
|
||||
}
|
||||
// lib.mapAttrs (
|
||||
name: msg:
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@
|
|||
}:
|
||||
let
|
||||
cfg = config.${namespace}.${name};
|
||||
opt = options.${namespace}.${name};
|
||||
opts = options.${namespace}.${name};
|
||||
|
||||
setupCode = ''
|
||||
require('${luaName}')${setup}(${
|
||||
|
|
@ -78,7 +78,7 @@
|
|||
inherit maintainers;
|
||||
nixvimInfo = {
|
||||
inherit description;
|
||||
url = args.url or opt.package.default.meta.homepage;
|
||||
url = args.url or opts.package.default.meta.homepage;
|
||||
path = [
|
||||
namespace
|
||||
name
|
||||
|
|
@ -146,7 +146,11 @@
|
|||
(lib.optionalAttrs (isColorscheme && (colorscheme != null)) {
|
||||
colorscheme = lib.mkDefault colorscheme;
|
||||
})
|
||||
(extraConfig cfg)
|
||||
(lib.optionalAttrs (args ? extraConfig) (
|
||||
lib.nixvim.modules.applyExtraConfig {
|
||||
inherit extraConfig cfg opts;
|
||||
}
|
||||
))
|
||||
]
|
||||
++ (lib.optionals (!hasConfigAttrs) [
|
||||
(lib.optionalAttrs callSetup (setLuaConfig setupCode))
|
||||
|
|
|
|||
|
|
@ -60,14 +60,14 @@
|
|||
}:
|
||||
let
|
||||
cfg = config.${namespace}.${name};
|
||||
opt = options.${namespace}.${name};
|
||||
opts = options.${namespace}.${name};
|
||||
in
|
||||
{
|
||||
meta = {
|
||||
inherit maintainers;
|
||||
nixvimInfo = {
|
||||
inherit description;
|
||||
url = args.url or opt.package.default.meta.homepage;
|
||||
url = args.url or opts.package.default.meta.homepage;
|
||||
path = [
|
||||
namespace
|
||||
name
|
||||
|
|
@ -115,7 +115,11 @@
|
|||
(lib.optionalAttrs (isColorscheme && (colorscheme != null)) {
|
||||
colorscheme = lib.mkDefault colorscheme;
|
||||
})
|
||||
(extraConfig cfg)
|
||||
(lib.optionalAttrs (args ? extraConfig) (
|
||||
lib.nixvim.modules.applyExtraConfig {
|
||||
inherit extraConfig cfg opts;
|
||||
}
|
||||
))
|
||||
]
|
||||
);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue