plugins/neotest: simplify implementation

This commit is contained in:
Gaetan Lepage 2024-03-19 10:11:49 +01:00 committed by Gaétan Lepage
parent 57d1062c04
commit 4708aac141
2 changed files with 12 additions and 40 deletions

View file

@ -33,11 +33,13 @@ with lib; let
You might want to set `plugins.treesitter.enable = true` and ensure that the `${props.treesitter-parser}` parser is enabled. You might want to set `plugins.treesitter.enable = true` and ensure that the `${props.treesitter-parser}` parser is enabled.
''; '';
plugins.neotest.enabledAdapters = [ plugins.neotest.settings.adapters = let
{ settingsString =
inherit name; optionalString
inherit (cfg) settings; (cfg.settings != {})
} "(${helpers.toLuaObject cfg.settings})";
in [
"require('neotest-${name}')${settingsString}"
]; ];
}; };
}; };

View file

@ -16,34 +16,18 @@ with lib;
./adapters.nix ./adapters.nix
]; ];
extraOptions = {
enabledAdapters = mkOption {
type = with types;
listOf
(submodule {
options = {
name = mkOption {
type = types.str;
};
settings = mkOption {
type = with types; attrsOf anything;
};
};
});
internal = true;
visible = false;
default = [];
};
};
settingsOptions = settingsOptions =
(import ./options.nix {inherit lib helpers;}) (import ./options.nix {inherit lib helpers;})
// { // {
adapters = mkOption { adapters = mkOption {
type = with helpers.nixvimTypes; listOf strLua; type = with helpers.nixvimTypes; listOf strLua;
default = []; default = [];
internal = true;
apply = map helpers.mkRaw; apply = map helpers.mkRaw;
# NOTE: We hide this option from the documentation as users should use the top-level
# `adapters` option.
# They can still directly append raw lua code to this `settings.adapters` option.
# In this case, they are responsible for explicitly installing the manually added adapters.
visible = false;
}; };
}; };
@ -58,18 +42,4 @@ with lib;
open = "botright split | resize 15"; open = "botright split | resize 15";
}; };
}; };
extraConfig = cfg: {
plugins.neotest.settings.adapters =
map
(
adapter: let
settingsString =
optionalString
(adapter.settings != {})
"(${helpers.toLuaObject adapter.settings})";
in "require('neotest-${adapter.name}')${settingsString}"
)
cfg.enabledAdapters;
};
} }