mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-27 02:59:00 +02:00
lib/option-warnings: add mkRemovedOption (#209)
This commit is contained in:
parent
101b721f6f
commit
c9abc97ee5
1 changed files with 23 additions and 10 deletions
|
@ -69,14 +69,27 @@ with lib; rec {
|
|||
overrideDescription = "Alias of ${showOption newOption}";
|
||||
};
|
||||
|
||||
# TODO:
|
||||
# mkRemovedOption =
|
||||
# { option
|
||||
# , visible ? false
|
||||
# }:
|
||||
# { options, ... }:
|
||||
# {
|
||||
# options = { };
|
||||
# config = { };
|
||||
# };
|
||||
mkRemovedOption = {
|
||||
option, # an array of the path to the option
|
||||
alternative ? null,
|
||||
message ? null,
|
||||
visible ? false,
|
||||
}: {
|
||||
options,
|
||||
config,
|
||||
...
|
||||
}: let
|
||||
fromOpt = getAttrFromPath option options;
|
||||
fromValue = getAttrFromPath option config;
|
||||
fullMessage =
|
||||
"The option `${showOption option}` has been removed."
|
||||
+ (optionalString (alternative != null) " You may want to use `${showOption alternative}` instead.")
|
||||
+ (optionalString (message != null) " Message: ${message}");
|
||||
in {
|
||||
config = mkIf (fromOpt.isDefined && fromValue != fromOpt.default) {
|
||||
warnings = [
|
||||
"Nixvim: ${fullMessage}"
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue