mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 00:25:42 +02:00
lib/mkSettingsRenamedOptionModules: allow attrs value with 'old' and 'new' keys
This commit is contained in:
parent
7e4f8a2a56
commit
0ddf6e39ac
1 changed files with 34 additions and 5 deletions
|
@ -47,16 +47,45 @@ rec {
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
Returns a function that maps
|
||||||
|
[
|
||||||
|
"someOption"
|
||||||
|
["fooBar" "someSubOption"]
|
||||||
|
{ old = "someOtherOption"; new = ["foo_bar" "some_other_option"]}
|
||||||
|
]
|
||||||
|
|
||||||
|
to
|
||||||
|
[
|
||||||
|
(lib.mkRenamedOptionModule
|
||||||
|
(oldPath ++ ["someOption"])
|
||||||
|
(newPath ++ ["some_option"])
|
||||||
|
)
|
||||||
|
(lib.mkRenamedOptionModule
|
||||||
|
(oldPath ++ ["fooBar" "someSubOption"])
|
||||||
|
(newPath ++ ["foo_bar" "some_sub_option"])
|
||||||
|
)
|
||||||
|
(lib.mkRenamedOptionModule
|
||||||
|
(oldPath ++ ["someOtherOption"])
|
||||||
|
(newPath ++ ["foo_bar" "some_other_option"])
|
||||||
|
)
|
||||||
|
]
|
||||||
|
*/
|
||||||
mkSettingsRenamedOptionModules =
|
mkSettingsRenamedOptionModules =
|
||||||
oldPrefix: newPrefix:
|
oldPrefix: newPrefix:
|
||||||
map (
|
map (
|
||||||
option':
|
spec:
|
||||||
let
|
let
|
||||||
option = lib.toList option';
|
finalSpec =
|
||||||
oldPath = oldPrefix ++ option;
|
if lib.isAttrs spec then
|
||||||
newPath = newPrefix ++ map lib.nixvim.toSnakeCase option;
|
lib.mapAttrs (_: lib.toList) spec
|
||||||
|
else
|
||||||
|
{
|
||||||
|
old = lib.toList spec;
|
||||||
|
new = map lib.nixvim.toSnakeCase finalSpec.old;
|
||||||
|
};
|
||||||
in
|
in
|
||||||
lib.mkRenamedOptionModule oldPath newPath
|
lib.mkRenamedOptionModule (oldPrefix ++ finalSpec.old) (newPrefix ++ finalSpec.new)
|
||||||
);
|
);
|
||||||
|
|
||||||
# A clone of types.coercedTo, but it prints a warning when oldType is used.
|
# A clone of types.coercedTo, but it prints a warning when oldType is used.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue