mirror of
https://github.com/nix-community/nixvim.git
synced 2025-08-14 14:48:47 +02:00
tests/plugins-by-name: simplify by-name-enable-opts impl
Instead of using a regex to match the absolute file path, remove the nixvim root path prefix.
This commit is contained in:
parent
09b736b7a1
commit
9d076b033d
1 changed files with 9 additions and 5 deletions
|
@ -5,9 +5,12 @@
|
||||||
runCommandLocal,
|
runCommandLocal,
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
|
nixvim-root = ../.;
|
||||||
by-name = ../plugins/by-name;
|
by-name = ../plugins/by-name;
|
||||||
options = lib.collect lib.isOption nixvimConfiguration.options;
|
options = lib.collect lib.isOption nixvimConfiguration.options;
|
||||||
|
|
||||||
|
toRelative = lib.removePrefix (toString nixvim-root);
|
||||||
|
|
||||||
# Option namespace expect by-name plugins to use
|
# Option namespace expect by-name plugins to use
|
||||||
namespace = "plugins";
|
namespace = "plugins";
|
||||||
|
|
||||||
|
@ -30,15 +33,16 @@ let
|
||||||
# Find plugins by looking for `*.*.enable` options that are declared in `plugins/by-name`
|
# Find plugins by looking for `*.*.enable` options that are declared in `plugins/by-name`
|
||||||
by-name-enable-opts =
|
by-name-enable-opts =
|
||||||
let
|
let
|
||||||
regex = ''/nix/store/[^/]+/plugins/by-name/(.*)'';
|
|
||||||
optionalPair =
|
optionalPair =
|
||||||
opt: file:
|
opt: file:
|
||||||
let
|
let
|
||||||
result = builtins.match regex file;
|
relative = toRelative file;
|
||||||
in
|
|
||||||
lib.optional (result != null) {
|
|
||||||
# Use the file name relative to `plugins/by-name/`
|
# Use the file name relative to `plugins/by-name/`
|
||||||
name = builtins.head result;
|
name = lib.removePrefix "plugins/by-name/" relative;
|
||||||
|
hasPrefix = name != relative;
|
||||||
|
in
|
||||||
|
lib.optional hasPrefix {
|
||||||
|
inherit name;
|
||||||
# Use only the first two parts of the option location
|
# Use only the first two parts of the option location
|
||||||
value = lib.genList (builtins.elemAt opt.loc) 2;
|
value = lib.genList (builtins.elemAt opt.loc) 2;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue