helpers/vim-plugin/mkVimPlugin: add optionsRenamedToSettings option

This commit is contained in:
Gaetan Lepage 2024-02-19 10:29:19 +01:00 committed by Gaétan Lepage
parent cef446a4da
commit b8815f04a3
2 changed files with 32 additions and 6 deletions

View file

@ -14,7 +14,7 @@ in
keymaps = import ./keymap-helpers.nix {inherit lib nixvimOptions nixvimTypes;};
autocmd = import ./autocmd-helpers.nix {inherit lib nixvimOptions nixvimTypes;};
neovim-plugin = import ./neovim-plugin.nix {inherit lib nixvimOptions nixvimUtils toLuaObject;};
vim-plugin = import ./vim-plugin.nix {inherit lib nixvimOptions;};
vim-plugin = import ./vim-plugin.nix {inherit lib nixvimOptions nixvimUtils;};
inherit nixvimTypes;
inherit toLuaObject;
}

View file

@ -1,6 +1,7 @@
{
lib,
nixvimOptions,
nixvimUtils,
}:
with lib; {
mkVimPlugin = config: {
@ -10,6 +11,7 @@ with lib; {
imports ? [],
# deprecations
deprecateExtraConfig ? false,
optionsRenamedToSettings ? [],
# options
originalName ? name,
defaultPackage ? null,
@ -88,12 +90,36 @@ with lib; {
// pluginOptions
// extraOptions;
imports =
imports = let
basePluginPath = [namespace name];
settingsPath = basePluginPath ++ ["settings"];
in
imports
++ optional (deprecateExtraConfig && createSettingsOption) (
mkRenamedOptionModule
["plugins" name "extraConfig"]
["plugins" name "settings"]
++ (
optional
(deprecateExtraConfig && createSettingsOption)
(
mkRenamedOptionModule
(basePluginPath ++ ["extraConfig"])
settingsPath
)
)
++ (
map
(
option: let
optionPath =
if isString option
then [option]
else option; # option is already a path (i.e. a list)
optionPathSnakeCase = map nixvimUtils.toSnakeCase optionPath;
in
mkRenamedOptionModule
(basePluginPath ++ optionPath)
(settingsPath ++ optionPathSnakeCase)
)
optionsRenamedToSettings
);
config =