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;}; keymaps = import ./keymap-helpers.nix {inherit lib nixvimOptions nixvimTypes;};
autocmd = import ./autocmd-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;}; 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 nixvimTypes;
inherit toLuaObject; inherit toLuaObject;
} }

View file

@ -1,6 +1,7 @@
{ {
lib, lib,
nixvimOptions, nixvimOptions,
nixvimUtils,
}: }:
with lib; { with lib; {
mkVimPlugin = config: { mkVimPlugin = config: {
@ -10,6 +11,7 @@ with lib; {
imports ? [], imports ? [],
# deprecations # deprecations
deprecateExtraConfig ? false, deprecateExtraConfig ? false,
optionsRenamedToSettings ? [],
# options # options
originalName ? name, originalName ? name,
defaultPackage ? null, defaultPackage ? null,
@ -88,12 +90,36 @@ with lib; {
// pluginOptions // pluginOptions
// extraOptions; // extraOptions;
imports = imports = let
basePluginPath = [namespace name];
settingsPath = basePluginPath ++ ["settings"];
in
imports imports
++ optional (deprecateExtraConfig && createSettingsOption) ( ++ (
mkRenamedOptionModule optional
["plugins" name "extraConfig"] (deprecateExtraConfig && createSettingsOption)
["plugins" name "settings"] (
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 = config =