mirror of
https://github.com/nix-community/nixvim.git
synced 2025-08-07 11:25:06 +02:00
Fixed deprecated option
This commit is contained in:
parent
d1278097c2
commit
f2dbecdf3f
1 changed files with 6 additions and 5 deletions
|
@ -10,15 +10,16 @@ rec {
|
||||||
, message ? null
|
, message ? null
|
||||||
, visible ? false
|
, visible ? false
|
||||||
}:
|
}:
|
||||||
{ options, ... }:
|
{ options, config, ... }:
|
||||||
let
|
let
|
||||||
fromOpt = getAttrFromPath option options;
|
fromOpt = getAttrFromPath option options;
|
||||||
|
fromValue = getAttrFromPath option config;
|
||||||
fullMessage = "The option `${showOption option}` has been deprecated, but might still work." +
|
fullMessage = "The option `${showOption option}` has been deprecated, but might still work." +
|
||||||
(optionalString (alternative != null) " You may want to use `${showOption alternative}` instead.") +
|
(optionalString (alternative != null) " You may want to use `${showOption alternative}` instead.") +
|
||||||
(optionalString (message != null) " Message: ${message}");
|
(optionalString (message != null) " Message: ${message}");
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
config = mkIf (fromOpt.isDefined) {
|
config = mkIf (fromOpt.isDefined && fromValue != fromOpt.default) {
|
||||||
warnings = [
|
warnings = [
|
||||||
("Nixvim: ${fullMessage}")
|
("Nixvim: ${fullMessage}")
|
||||||
];
|
];
|
||||||
|
@ -35,8 +36,8 @@ rec {
|
||||||
{ options, ... }:
|
{ options, ... }:
|
||||||
let
|
let
|
||||||
fromOpt = getAttrFromPath option options;
|
fromOpt = getAttrFromPath option options;
|
||||||
toOf = attrByPath newOption
|
# toOf = attrByPath newOption
|
||||||
(abort "Renaming error: option `${showOption newOption}` does not exist.");
|
# (abort "Renaming error: option `${showOption newOption}` does not exist.");
|
||||||
toType = let opt = attrByPath newOption { } options; in
|
toType = let opt = attrByPath newOption { } options; in
|
||||||
opt.type or (types.submodule { });
|
opt.type or (types.submodule { });
|
||||||
message = "`${showOption option}` has been renamed to `${showOption newOption}`, but can still be used for compatibility";
|
message = "`${showOption option}` has been renamed to `${showOption newOption}`, but can still be used for compatibility";
|
||||||
|
@ -54,7 +55,7 @@ rec {
|
||||||
});
|
});
|
||||||
config = mkMerge [
|
config = mkMerge [
|
||||||
{
|
{
|
||||||
warnings = mkIf (warn) [ "Nixvim: ${message}" ];
|
warnings = mkIf (warn && fromOpt.isDefined) [ "Nixvim: ${message}" ];
|
||||||
}
|
}
|
||||||
(mkAliasAndWrapDefinitions (setAttrByPath newOption) fromOpt)
|
(mkAliasAndWrapDefinitions (setAttrByPath newOption) fromOpt)
|
||||||
];
|
];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue