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,
|
||||
}:
|
||||
let
|
||||
nixvim-root = ../.;
|
||||
by-name = ../plugins/by-name;
|
||||
options = lib.collect lib.isOption nixvimConfiguration.options;
|
||||
|
||||
toRelative = lib.removePrefix (toString nixvim-root);
|
||||
|
||||
# Option namespace expect by-name plugins to use
|
||||
namespace = "plugins";
|
||||
|
||||
|
@ -30,15 +33,16 @@ let
|
|||
# Find plugins by looking for `*.*.enable` options that are declared in `plugins/by-name`
|
||||
by-name-enable-opts =
|
||||
let
|
||||
regex = ''/nix/store/[^/]+/plugins/by-name/(.*)'';
|
||||
optionalPair =
|
||||
opt: file:
|
||||
let
|
||||
result = builtins.match regex file;
|
||||
in
|
||||
lib.optional (result != null) {
|
||||
relative = toRelative file;
|
||||
# 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
|
||||
value = lib.genList (builtins.elemAt opt.loc) 2;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue