Skip to content

Commit e3ec1c4

Browse files
khanelimanGaetanLepage
authored andcommitted
plugins/which-key: move listOfLen to lib.types
Allows us to require a list to have a certain length for plugins that request it.
1 parent 4eb2ad7 commit e3ec1c4

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

lib/types.nix

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,15 @@ rec {
8181

8282
# Overridden when building the documentation
8383
eitherRecursive = either;
84+
85+
listOfLen =
86+
elemType: len:
87+
addCheck (listOf elemType) (v: builtins.length v == len)
88+
// {
89+
description = "list of ${toString len} ${
90+
optionDescriptionPhrase (class: class == "noun" || class == "composite") elemType
91+
}";
92+
};
8493
}
8594
# Allow to do `with nixvimTypes;` instead of `with types;`
8695
// lib.types

plugins/utils/which-key.nix

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,6 @@ let
1010
inherit (lib.nixvim) defaultNullOpts mkRaw toLuaObject;
1111
types = lib.nixvim.nixvimTypes;
1212

13-
listOfLen =
14-
elemType: len:
15-
types.addCheck (types.listOf elemType) (v: length v == len)
16-
// {
17-
description = "list of ${toString len} ${
18-
types.optionDescriptionPhrase (class: class == "noun" || class == "composite") elemType
19-
}";
20-
};
21-
2213
opt = options.plugins.which-key;
2314
in
2415
lib.nixvim.neovim-plugin.mkNeovimPlugin config {
@@ -332,7 +323,7 @@ lib.nixvim.neovim-plugin.mkNeovimPlugin config {
332323
Supports all available border types from `vim.api.keyset.win_config.border`.
333324
'';
334325

335-
padding = defaultNullOpts.mkNullable (listOfLen types.int 2) [
326+
padding = defaultNullOpts.mkNullable (types.listOfLen types.int 2) [
336327
1
337328
2
338329
] "Extra window padding, in the form `[top/bottom, right/left]`.";

0 commit comments

Comments
 (0)