Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions lib/deprecation.nix
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,18 @@ rec {
'';
};

mkSettingsRenamedOptionModules =
oldPrefix: newPrefix:
map (
option':
let
option = toList option';
oldPath = oldPrefix ++ option;
newPath = newPrefix ++ map nixvim.toSnakeCase option;
in
mkRenamedOptionModule oldPath newPath
);

# A clone of types.coercedTo, but it prints a warning when oldType is used.
transitionType =
oldType: coerceFn: newType:
Expand Down
7 changes: 6 additions & 1 deletion lib/helpers.nix
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@ let
byteCompileLuaDrv
;

inherit (helpers.deprecation) getOptionRecursive mkDeprecatedSubOptionModule transitionType;
inherit (helpers.deprecation)
getOptionRecursive
mkDeprecatedSubOptionModule
mkSettingsRenamedOptionModules
transitionType
;

inherit (helpers.options)
defaultNullOpts
Expand Down
10 changes: 1 addition & 9 deletions lib/neovim-plugin.nix
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,7 @@ with lib;
++ (optional deprecateExtraOptions (
mkRenamedOptionModule (basePluginPath ++ [ "extraOptions" ]) settingsPath
))
++ (map (
option:
let
optionPath = if isString option then [ option ] else option; # option is already a path (i.e. a list)

optionPathSnakeCase = map helpers.toSnakeCase optionPath;
in
mkRenamedOptionModule (basePluginPath ++ optionPath) (settingsPath ++ optionPathSnakeCase)
) optionsRenamedToSettings);
++ (nixvim.mkSettingsRenamedOptionModules basePluginPath settingsPath optionsRenamedToSettings);

options.${namespace}.${name} =
{
Expand Down
9 changes: 9 additions & 0 deletions lib/types.nix
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,15 @@ rec {

# Overridden when building the documentation
eitherRecursive = either;

listOfLen =
elemType: len:
addCheck (listOf elemType) (v: builtins.length v == len)
// {
description = "list of ${toString len} ${
optionDescriptionPhrase (class: class == "noun" || class == "composite") elemType
}";
};
}
# Allow to do `with nixvimTypes;` instead of `with types;`
// lib.types
10 changes: 1 addition & 9 deletions lib/vim-plugin.nix
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,7 @@ with lib;
++ (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 helpers.toSnakeCase optionPath;
in
mkRenamedOptionModule (basePluginPath ++ optionPath) (settingsPath ++ optionPathSnakeCase)
) optionsRenamedToSettings);
++ (nixvim.mkSettingsRenamedOptionModules basePluginPath settingsPath optionsRenamedToSettings);

config = mkIf cfg.enable (mkMerge [
{
Expand Down
Loading