treewide: Reformat with nixfmt

This commit is contained in:
traxys 2024-05-05 19:39:35 +02:00
parent c6281260dc
commit 62f32bfc71
459 changed files with 28139 additions and 26377 deletions

View file

@ -5,48 +5,48 @@
pkgs,
...
}:
with lib; let
with lib;
let
supportedAdapters = import ./adapters-list.nix;
mkAdapter = name: {
treesitter-parser,
packageName ? "neotest-${name}",
settingsSuffix ? settingsLua: "(${settingsLua})",
}: {
options.plugins.neotest.adapters.${name} = {
enable = mkEnableOption name;
mkAdapter =
name:
{
treesitter-parser,
packageName ? "neotest-${name}",
settingsSuffix ? settingsLua: "(${settingsLua})",
}:
{
options.plugins.neotest.adapters.${name} = {
enable = mkEnableOption name;
package = helpers.mkPackageOption name pkgs.vimPlugins.${packageName};
package = helpers.mkPackageOption name pkgs.vimPlugins.${packageName};
settings = helpers.mkSettingsOption {
description = "settings for the `${name}` adapter.";
settings = helpers.mkSettingsOption { description = "settings for the `${name}` adapter."; };
};
};
config = let
cfg = config.plugins.neotest.adapters.${name};
in
mkIf cfg.enable {
extraPlugins = [cfg.package];
config =
let
cfg = config.plugins.neotest.adapters.${name};
in
mkIf cfg.enable {
extraPlugins = [ cfg.package ];
warnings =
optional
(!config.plugins.treesitter.enable)
''
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 (helpers.toLuaObject cfg.settings));
in [
"require('neotest-${name}')${settingsString}"
];
};
};
in {
plugins.neotest.settings.adapters =
let
settingsString = optionalString (cfg.settings != { }) (
settingsSuffix (helpers.toLuaObject cfg.settings)
);
in
[ "require('neotest-${name}')${settingsString}" ];
};
};
in
{
imports = mapAttrsToList mkAdapter supportedAdapters;
}

View file

@ -6,40 +6,36 @@
...
}:
with lib;
helpers.neovim-plugin.mkNeovimPlugin config {
name = "neotest";
defaultPackage = pkgs.vimPlugins.neotest;
helpers.neovim-plugin.mkNeovimPlugin config {
name = "neotest";
defaultPackage = pkgs.vimPlugins.neotest;
maintainers = [maintainers.GaetanLepage];
maintainers = [ maintainers.GaetanLepage ];
imports = [
./adapters.nix
];
imports = [ ./adapters.nix ];
settingsOptions =
(import ./options.nix {inherit lib helpers;})
// {
adapters = mkOption {
type = with helpers.nixvimTypes; listOf strLua;
default = [];
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;
};
};
settingsExample = {
quickfix.enabled = false;
output = {
enabled = true;
open_on_run = true;
};
output_panel = {
enabled = true;
open = "botright split | resize 15";
};
settingsOptions = (import ./options.nix { inherit lib helpers; }) // {
adapters = mkOption {
type = with helpers.nixvimTypes; listOf strLua;
default = [ ];
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;
};
}
};
settingsExample = {
quickfix.enabled = false;
output = {
enabled = true;
open_on_run = true;
};
output_panel = {
enabled = true;
open = "botright split | resize 15";
};
};
}

View file

@ -1,8 +1,6 @@
{ lib, helpers }:
with lib;
{
lib,
helpers,
}:
with lib; {
#################################################
# CoreConfig
@ -45,53 +43,47 @@ with lib; {
value: lua function
'';
icons =
helpers.defaultNullOpts.mkAttrsOf (with types; either str (listOf str))
''
{
child_indent = "";
child_prefix = "";
collapsed = "";
expanded = "";
failed = "";
final_child_indent = " ";
final_child_prefix = "";
non_collapsible = "";
passed = "";
running = "";
running_animated = ["/" "|" "\\" "-" "/" "|" "\\" "-"];
skipped = "";
unknown = "";
watching = "";
}
''
"Icons used throughout the UI. Defaults use VSCode's codicons.";
icons = helpers.defaultNullOpts.mkAttrsOf (with types; either str (listOf str)) ''
{
child_indent = "";
child_prefix = "";
collapsed = "";
expanded = "";
failed = "";
final_child_indent = " ";
final_child_prefix = "";
non_collapsible = "";
passed = "";
running = "";
running_animated = ["/" "|" "\\" "-" "/" "|" "\\" "-"];
skipped = "";
unknown = "";
watching = "";
}
'' "Icons used throughout the UI. Defaults use VSCode's codicons.";
highlights =
helpers.defaultNullOpts.mkAttrsOf types.str
''
{
adapter_name = "NeotestAdapterName";
border = "NeotestBorder";
dir = "NeotestDir";
expand_marker = "NeotestExpandMarker";
failed = "NeotestFailed";
file = "NeotestFile";
focused = "NeotestFocused";
indent = "NeotestIndent";
marked = "NeotestMarked";
namespace = "NeotestNamespace";
passed = "NeotestPassed";
running = "NeotestRunning";
select_win = "NeotestWinSelect";
skipped = "NeotestSkipped";
target = "NeotestTarget";
test = "NeotestTest";
unknown = "NeotestUnknown";
watching = "NeotestWatching";
}
''
"";
highlights = helpers.defaultNullOpts.mkAttrsOf types.str ''
{
adapter_name = "NeotestAdapterName";
border = "NeotestBorder";
dir = "NeotestDir";
expand_marker = "NeotestExpandMarker";
failed = "NeotestFailed";
file = "NeotestFile";
focused = "NeotestFocused";
indent = "NeotestIndent";
marked = "NeotestMarked";
namespace = "NeotestNamespace";
passed = "NeotestPassed";
running = "NeotestRunning";
select_win = "NeotestWinSelect";
skipped = "NeotestSkipped";
target = "NeotestTarget";
test = "NeotestTest";
unknown = "NeotestUnknown";
watching = "NeotestWatching";
}
'' "";
floating = {
border = helpers.defaultNullOpts.mkStr "rounded" "Border style.";
@ -130,31 +122,28 @@ with lib; {
expandErrors = helpers.defaultNullOpts.mkBool true "Expand all failed positions.";
mappings =
helpers.defaultNullOpts.mkAttrsOf (with types; either str (listOf str))
''
{
attach = "a";
clear_marked = "M";
clear_target = "T";
debug = "d";
debug_marked = "D";
expand = ["<CR>" "<2-LeftMouse>"];
expand_all = "e";
jumpto = "i";
mark = "m";
next_failed = "J";
output = "o";
prev_failed = "K";
run = "r";
run_marked = "R";
short = "O";
stop = "u";
target = "t";
watch = "w";
}
''
"Buffer mappings for summary window.";
mappings = helpers.defaultNullOpts.mkAttrsOf (with types; either str (listOf str)) ''
{
attach = "a";
clear_marked = "M";
clear_target = "T";
debug = "d";
debug_marked = "D";
expand = ["<CR>" "<2-LeftMouse>"];
expand_all = "e";
jumpto = "i";
mark = "m";
next_failed = "J";
output = "o";
prev_failed = "K";
run = "r";
run_marked = "R";
short = "O";
stop = "u";
target = "t";
watch = "w";
}
'' "Buffer mappings for summary window.";
open = helpers.defaultNullOpts.mkStr "botright vsplit | vertical resize 50" ''
A command or function to open a window for the summary.
@ -203,17 +192,11 @@ with lib; {
watch = {
enabled = helpers.defaultNullOpts.mkBool true "Enable watch.";
symbol_queries =
helpers.mkNullOrOption
(
with helpers.nixvimTypes;
attrsOf (maybeRaw str)
)
''
Treesitter queries or functions to capture symbols that are used for querying the LSP
server for definitions to link files.
If it is a function then the return value should be a list of node ranges.
'';
symbol_queries = helpers.mkNullOrOption (with helpers.nixvimTypes; attrsOf (maybeRaw str)) ''
Treesitter queries or functions to capture symbols that are used for querying the LSP
server for definitions to link files.
If it is a function then the return value should be a list of node ranges.
'';
filter_path = helpers.mkNullOrLuaFn ''
`(fun(path: string, root: string): boolean)`