lib/modules: add applyExtraConfig

Used for
- mkVimPlugin: extraConfig
- mkNeovimPlugin: extraConfig
- mkLsp: extraConfig
- mkLsp: settings
- mkExtension (telecsope): extraConfig
This commit is contained in:
Matt Sturgeon 2024-11-19 13:55:33 +00:00
parent c7b7b6481b
commit 63cfc84abe
No known key found for this signature in database
GPG key ID: 4F91844CED1A8299
6 changed files with 69 additions and 14 deletions

View file

@ -29,14 +29,14 @@
with lib;
let
cfg = config.plugins.lsp.servers.${name};
opt = options.plugins.lsp.servers.${name};
opts = options.plugins.lsp.servers.${name};
enabled = config.plugins.lsp.enable && cfg.enable;
in
{
meta.nixvimInfo = {
# TODO: description
url = args.url or opt.package.default.meta.homepage or null;
url = args.url or opts.package.default.meta.homepage or null;
path = [
"plugins"
"lsp"
@ -70,7 +70,7 @@ in
type = with types; nullOr (listOf str);
default =
# TODO: do we really only want the default `cmd` when `package` is non-null?
if !(opt.package.isDefined or false) then
if !(opts.package.isDefined or false) then
null
else if cfg.package == null then
null
@ -150,7 +150,12 @@ in
end
''
);
settings = settings cfg.settings;
settings = lib.nixvim.modules.applyExtraConfig {
extraConfig = settings;
cfg = cfg.settings;
opts = opts.settings;
enabled = true;
};
} // cfg.extraOptions;
}
];
@ -170,8 +175,17 @@ in
(mkRemovedOptionModule (
basePluginPath ++ [ "extraSettings" ]
) "You can use `${basePluginPathString}.extraOptions.settings` instead.")
(lib.mkIf enabled (extraConfig cfg))
]
++ lib.optional (args ? extraConfig) (
lib.nixvim.modules.applyExtraConfig {
inherit
extraConfig
cfg
opts
enabled
;
}
)
# Add an alias (with warning) for the lspconfig server name, if different to `name`.
# Note: users may use lspconfig's docs to guess the `plugins.lsp.servers.*` name
++ (optional (name != serverName) (