Skip to content

Commit db4c4e5

Browse files
khanelimanGaetanLepage
authored andcommitted
lib/deprecation: expose mkSettingsRenamedOptionModules publicly
Extracted the `optionsRenamedToSettings` implementation from`mkVimPlugin` and `mkNeovimPlugin` into a new public helper.
1 parent e3ec1c4 commit db4c4e5

File tree

4 files changed

+20
-19
lines changed

4 files changed

+20
-19
lines changed

lib/deprecation.nix

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,18 @@ rec {
4646
'';
4747
};
4848

49+
mkSettingsRenamedOptionModules =
50+
oldPrefix: newPrefix:
51+
map (
52+
option':
53+
let
54+
option = toList option';
55+
oldPath = oldPrefix ++ option;
56+
newPath = newPrefix ++ map nixvim.toSnakeCase option;
57+
in
58+
mkRenamedOptionModule oldPath newPath
59+
);
60+
4961
# A clone of types.coercedTo, but it prints a warning when oldType is used.
5062
transitionType =
5163
oldType: coerceFn: newType:

lib/helpers.nix

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,12 @@ let
3838
byteCompileLuaDrv
3939
;
4040

41-
inherit (helpers.deprecation) getOptionRecursive mkDeprecatedSubOptionModule transitionType;
41+
inherit (helpers.deprecation)
42+
getOptionRecursive
43+
mkDeprecatedSubOptionModule
44+
mkSettingsRenamedOptionModules
45+
transitionType
46+
;
4247

4348
inherit (helpers.options)
4449
defaultNullOpts

lib/neovim-plugin.nix

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,7 @@ with lib;
7171
++ (optional deprecateExtraOptions (
7272
mkRenamedOptionModule (basePluginPath ++ [ "extraOptions" ]) settingsPath
7373
))
74-
++ (map (
75-
option:
76-
let
77-
optionPath = if isString option then [ option ] else option; # option is already a path (i.e. a list)
78-
79-
optionPathSnakeCase = map helpers.toSnakeCase optionPath;
80-
in
81-
mkRenamedOptionModule (basePluginPath ++ optionPath) (settingsPath ++ optionPathSnakeCase)
82-
) optionsRenamedToSettings);
74+
++ (nixvim.mkSettingsRenamedOptionModules basePluginPath settingsPath optionsRenamedToSettings);
8375

8476
options.${namespace}.${name} =
8577
{

lib/vim-plugin.nix

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,7 @@ with lib;
8686
++ (optional (deprecateExtraConfig && createSettingsOption) (
8787
mkRenamedOptionModule (basePluginPath ++ [ "extraConfig" ]) settingsPath
8888
))
89-
++ (map (
90-
option:
91-
let
92-
optionPath = if isString option then [ option ] else option; # option is already a path (i.e. a list)
93-
94-
optionPathSnakeCase = map helpers.toSnakeCase optionPath;
95-
in
96-
mkRenamedOptionModule (basePluginPath ++ optionPath) (settingsPath ++ optionPathSnakeCase)
97-
) optionsRenamedToSettings);
89+
++ (nixvim.mkSettingsRenamedOptionModules basePluginPath settingsPath optionsRenamedToSettings);
9890

9991
config = mkIf cfg.enable (mkMerge [
10092
{

0 commit comments

Comments
 (0)