mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-26 10:48:35 +02:00
plugins/neotest: move to by-name
This commit is contained in:
parent
0f83298f2c
commit
9d323f3ec7
26 changed files with 0 additions and 2 deletions
62
plugins/by-name/neotest/adapters.nix
Normal file
62
plugins/by-name/neotest/adapters.nix
Normal file
|
@ -0,0 +1,62 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
let
|
||||
inherit (lib.nixvim) mkSettingsOption toLuaObject;
|
||||
supportedAdapters = import ./adapters-list.nix;
|
||||
|
||||
mkAdapter =
|
||||
name:
|
||||
{
|
||||
treesitter-parser,
|
||||
packageName ? "neotest-${name}",
|
||||
settingsSuffix ? settingsLua: "(${settingsLua})",
|
||||
}:
|
||||
{
|
||||
options.plugins.neotest.adapters.${name} = {
|
||||
enable = mkEnableOption name;
|
||||
|
||||
package = lib.mkPackageOption pkgs name {
|
||||
default = [
|
||||
"vimPlugins"
|
||||
packageName
|
||||
];
|
||||
};
|
||||
|
||||
settings = mkSettingsOption { description = "settings for the `${name}` adapter."; };
|
||||
};
|
||||
|
||||
config =
|
||||
let
|
||||
cfg = config.plugins.neotest.adapters.${name};
|
||||
in
|
||||
mkIf cfg.enable {
|
||||
extraPlugins = [ cfg.package ];
|
||||
|
||||
assertions = [
|
||||
{
|
||||
assertion = config.plugins.neotest.enable;
|
||||
message = "Nixvim: you have enabled `plugins.neotest.adapters.${name}` but `plugins.neotest.enable` is `false`.";
|
||||
}
|
||||
];
|
||||
|
||||
warnings = optional (!config.plugins.treesitter.enable) ''
|
||||
Nixvim (plugins.neotest.adapters.${name}): This adapter requires `treesitter` to be enabled.
|
||||
You might want to set `plugins.treesitter.enable = true` and ensure that the `${props.treesitter-parser}` parser is enabled.
|
||||
'';
|
||||
|
||||
plugins.neotest.settings.adapters =
|
||||
let
|
||||
settingsString = optionalString (cfg.settings != { }) (settingsSuffix (toLuaObject cfg.settings));
|
||||
in
|
||||
[ "require('neotest-${name}')${settingsString}" ];
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
imports = mapAttrsToList mkAdapter supportedAdapters;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue