mirror of
https://github.com/nix-community/nixvim.git
synced 2025-08-09 20:35:10 +02:00
added warnings module
This commit is contained in:
parent
e607ab67a5
commit
5a222885fc
5 changed files with 65 additions and 8 deletions
31
lib/option-warnings.nix
Normal file
31
lib/option-warnings.nix
Normal file
|
@ -0,0 +1,31 @@
|
|||
{ lib, ... }:
|
||||
with lib;
|
||||
|
||||
rec {
|
||||
mkDeprecatedOption =
|
||||
{ option # an array of the path to the option
|
||||
, alternative ? null
|
||||
, message ? null
|
||||
, visible ? false
|
||||
, ...
|
||||
}:
|
||||
{ options, ... }:
|
||||
let
|
||||
fromOpt = getAttrFromPath option options;
|
||||
fullMessage = "The option `${showOption option}` has been deprecated." +
|
||||
(optionalString (alternative != null) " You may want to use `${showOption alternative}` instead.") +
|
||||
(optionalString (message != null) " Message: ${message}");
|
||||
in
|
||||
{
|
||||
options = setAttrByPath option
|
||||
(mkOption {
|
||||
inherit visible;
|
||||
description = fullMessage;
|
||||
});
|
||||
config = mkIf (fromOpt.isDefined) {
|
||||
warnings = [
|
||||
("Nixvim: ${fullMessage}")
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue