plugins/lsp: deprecate extraSettings

This commit is contained in:
Gaetan Lepage 2023-12-02 19:03:20 +01:00 committed by Gaétan Lepage
parent 944a84b2c0
commit ae3a47674b

View file

@ -1,9 +1,4 @@
{ {pkgs, ...}: {
lib,
pkgs,
config,
...
}: {
mkLsp = { mkLsp = {
name, name,
description ? "Enable ${name}.", description ? "Enable ${name}.",
@ -92,13 +87,6 @@
settings = settingsOptions; settings = settingsOptions;
extraSettings = mkOption {
type = types.attrs;
description = ''
Extra settings for the ${name} language server.
'';
};
extraOptions = mkOption { extraOptions = mkOption {
default = {}; default = {};
type = types.attrs; type = types.attrs;
@ -108,10 +96,7 @@
// packageOption; // packageOption;
}; };
config = let config =
extraSettingsOption = options.plugins.lsp.servers.${name}.extraSettings;
extraSettingsAreDefined = extraSettingsOption.isDefined;
in
mkIf cfg.enable mkIf cfg.enable
{ {
extraPackages = extraPackages =
@ -136,25 +121,21 @@
end end
'' ''
); );
settings = settings = settings cfg.settings;
(settings cfg.settings)
// (
if extraSettingsAreDefined
then cfg.extraSettings
else {}
);
} }
// cfg.extraOptions; // cfg.extraOptions;
} }
]; ];
warnings =
optional extraSettingsAreDefined
(
let
optionPrefix = "plugins.lsp.servers.${name}";
in "The `${optionPrefix}.extraSettings` option is deprecated in favor of `${optionPrefix}.extraOptions.settings`."
);
}; };
imports = let
basePluginPath = ["plugins" "lsp" "servers" name];
basePluginPathString = concatStringsSep "." basePluginPath;
in [
(
mkRemovedOptionModule
(basePluginPath ++ ["extraSettings"])
"You can use `${basePluginPathString}.extraOptions.settings` instead."
)
];
}; };
} }