Skip to content

Commit 09b736b

Browse files
committed
tests/plugins-by-name: simplify namespace assertion
1 parent 14f5ea7 commit 09b736b

File tree

1 file changed

+5
-15
lines changed

1 file changed

+5
-15
lines changed

tests/plugins-by-name.nix

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,8 @@ let
88
by-name = ../plugins/by-name;
99
options = lib.collect lib.isOption nixvimConfiguration.options;
1010

11-
# Option namespaces that we allow by-name plugins to declare
12-
knownPluginNamespaces = [
13-
"colorschemes"
14-
"plugins"
15-
];
11+
# Option namespace expect by-name plugins to use
12+
namespace = "plugins";
1613

1714
# Group by-name children by filetype; "regular", "directory", "symlink" and "unknown".
1815
children =
@@ -157,17 +154,10 @@ linkFarmFromDrvs "plugins-by-name" [
157154
{
158155
__structuredAttrs = true;
159156

160-
# I'm sorry, I couldn't help implementing oxford-comma...
161-
expected =
162-
let
163-
len = builtins.length knownPluginNamespaces;
164-
in
165-
lib.concatImapStringsSep ", " (
166-
i: str: lib.optionalString (i > 1 && i == len) "or " + "`${str}`"
167-
) knownPluginNamespaces;
157+
inherit namespace;
168158

169159
options = lib.pipe by-name-enable-opts [
170-
(lib.filterAttrs (file: loc: !(builtins.elem (builtins.head loc) knownPluginNamespaces)))
160+
(lib.filterAttrs (file: loc: builtins.head loc != namespace))
171161
(lib.mapAttrs (file: loc: "`${lib.showOption loc}`"))
172162
];
173163

@@ -178,7 +168,7 @@ linkFarmFromDrvs "plugins-by-name" [
178168
''
179169
if (( ''${#options[@]} > 0 )); then
180170
echo "Found plugin modules with unknown option namespaces (''${#options[@]})"
181-
echo "Expected all plugins to be scoped as $expected"
171+
echo "Expected all plugins to be scoped as $namespace"
182172
for file in "''${!options[@]}"; do
183173
echo "- ''${options[$file]} is declared in '$file'"
184174
done

0 commit comments

Comments
 (0)