plugins/which-key: move listOfLen to lib.types

Allows us to require a list to have a certain length for plugins that
request it.
This commit is contained in:
Austin Horstman 2024-08-13 08:05:55 -05:00 committed by GaetanLepage
parent 4eb2ad7db7
commit e3ec1c4a46
2 changed files with 10 additions and 10 deletions

View file

@ -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

View file

@ -10,15 +10,6 @@ let
inherit (lib.nixvim) defaultNullOpts mkRaw toLuaObject;
types = lib.nixvim.nixvimTypes;
listOfLen =
elemType: len:
types.addCheck (types.listOf elemType) (v: length v == len)
// {
description = "list of ${toString len} ${
types.optionDescriptionPhrase (class: class == "noun" || class == "composite") elemType
}";
};
opt = options.plugins.which-key;
in
lib.nixvim.neovim-plugin.mkNeovimPlugin config {
@ -332,7 +323,7 @@ lib.nixvim.neovim-plugin.mkNeovimPlugin config {
Supports all available border types from `vim.api.keyset.win_config.border`.
'';
padding = defaultNullOpts.mkNullable (listOfLen types.int 2) [
padding = defaultNullOpts.mkNullable (types.listOfLen types.int 2) [
1
2
] "Extra window padding, in the form `[top/bottom, right/left]`.";