mirror of
https://github.com/nix-community/nixvim.git
synced 2025-08-14 22:52:29 +02:00
tests/plugins-by-name: simplify namespace assertion
This commit is contained in:
parent
14f5ea7431
commit
09b736b7a1
1 changed files with 5 additions and 15 deletions
|
@ -8,11 +8,8 @@ let
|
||||||
by-name = ../plugins/by-name;
|
by-name = ../plugins/by-name;
|
||||||
options = lib.collect lib.isOption nixvimConfiguration.options;
|
options = lib.collect lib.isOption nixvimConfiguration.options;
|
||||||
|
|
||||||
# Option namespaces that we allow by-name plugins to declare
|
# Option namespace expect by-name plugins to use
|
||||||
knownPluginNamespaces = [
|
namespace = "plugins";
|
||||||
"colorschemes"
|
|
||||||
"plugins"
|
|
||||||
];
|
|
||||||
|
|
||||||
# Group by-name children by filetype; "regular", "directory", "symlink" and "unknown".
|
# Group by-name children by filetype; "regular", "directory", "symlink" and "unknown".
|
||||||
children =
|
children =
|
||||||
|
@ -157,17 +154,10 @@ linkFarmFromDrvs "plugins-by-name" [
|
||||||
{
|
{
|
||||||
__structuredAttrs = true;
|
__structuredAttrs = true;
|
||||||
|
|
||||||
# I'm sorry, I couldn't help implementing oxford-comma...
|
inherit namespace;
|
||||||
expected =
|
|
||||||
let
|
|
||||||
len = builtins.length knownPluginNamespaces;
|
|
||||||
in
|
|
||||||
lib.concatImapStringsSep ", " (
|
|
||||||
i: str: lib.optionalString (i > 1 && i == len) "or " + "`${str}`"
|
|
||||||
) knownPluginNamespaces;
|
|
||||||
|
|
||||||
options = lib.pipe by-name-enable-opts [
|
options = lib.pipe by-name-enable-opts [
|
||||||
(lib.filterAttrs (file: loc: !(builtins.elem (builtins.head loc) knownPluginNamespaces)))
|
(lib.filterAttrs (file: loc: builtins.head loc != namespace))
|
||||||
(lib.mapAttrs (file: loc: "`${lib.showOption loc}`"))
|
(lib.mapAttrs (file: loc: "`${lib.showOption loc}`"))
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -178,7 +168,7 @@ linkFarmFromDrvs "plugins-by-name" [
|
||||||
''
|
''
|
||||||
if (( ''${#options[@]} > 0 )); then
|
if (( ''${#options[@]} > 0 )); then
|
||||||
echo "Found plugin modules with unknown option namespaces (''${#options[@]})"
|
echo "Found plugin modules with unknown option namespaces (''${#options[@]})"
|
||||||
echo "Expected all plugins to be scoped as $expected"
|
echo "Expected all plugins to be scoped as $namespace"
|
||||||
for file in "''${!options[@]}"; do
|
for file in "''${!options[@]}"; do
|
||||||
echo "- ''${options[$file]} is declared in '$file'"
|
echo "- ''${options[$file]} is declared in '$file'"
|
||||||
done
|
done
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue