plugins/dap: remove helpers

This commit is contained in:
Austin Horstman 2025-01-23 20:11:11 -06:00
parent e48dda4fe4
commit 216ae2bf40
No known key found for this signature in database
6 changed files with 108 additions and 103 deletions

View file

@ -1,35 +1,36 @@
{ lib, helpers }:
{ lib }:
let
inherit (lib) types;
inherit (lib.nixvim) mkNullOrOption;
in
rec {
mkAdapterType =
attrs:
types.submodule {
options = {
id = helpers.mkNullOrOption types.str ''
id = mkNullOrOption types.str ''
Identifier of the adapter. This is used for the
`adapterId` property of the initialize request.
For most debug adapters setting this is not necessary.
'';
enrichConfig = helpers.mkNullOrLuaFn ''
enrichConfig = lib.nixvim.mkNullOrLuaFn ''
A lua function (`func(config, on_config)`) which allows an adapter to enrich a
configuration with additional information. It receives a configuration as first
argument, and a callback that must be called with the final configuration as second argument.
'';
options = {
initializeTimeoutSec = helpers.defaultNullOpts.mkInt 4 ''
initializeTimeoutSec = lib.nixvim.defaultNullOpts.mkInt 4 ''
How many seconds the client waits for a response on a initialize request before emitting a warning.
'';
disconnectTimeoutSec = helpers.defaultNullOpts.mkInt 3 ''
disconnectTimeoutSec = lib.nixvim.defaultNullOpts.mkInt 3 ''
How many seconds the client waits for a disconnect response from the debug
adapter before emitting a warning and closing the connection.
'';
sourceFiletype = helpers.mkNullOrOption types.str ''
sourceFiletype = mkNullOrOption types.str ''
The filetype to use for content retrieved via a source request.
'';
};
@ -37,39 +38,39 @@ rec {
};
executableAdapterOption = mkAdapterType {
command = helpers.mkNullOrOption types.str "The command to invoke.";
command = mkNullOrOption types.str "The command to invoke.";
args = helpers.mkNullOrOption (types.listOf types.str) "Arguments for the command.";
args = mkNullOrOption (types.listOf types.str) "Arguments for the command.";
options = {
env = helpers.mkNullOrOption types.attrs "Set the environment variables for the command.";
env = mkNullOrOption types.attrs "Set the environment variables for the command.";
cwd = helpers.mkNullOrOption types.str "Set the working directory for the command.";
cwd = mkNullOrOption types.str "Set the working directory for the command.";
detached = helpers.defaultNullOpts.mkBool true "Start the debug adapter in a detached state.";
detached = lib.nixvim.defaultNullOpts.mkBool true "Start the debug adapter in a detached state.";
};
};
serverAdapterOption = mkAdapterType {
host = helpers.defaultNullOpts.mkStr "127.0.0.1" "Host to connect to.";
host = lib.nixvim.defaultNullOpts.mkStr "127.0.0.1" "Host to connect to.";
port = helpers.mkNullOrOption (types.either types.int (types.enum [ "$\{port}" ])) ''
port = mkNullOrOption (types.either types.int (types.enum [ "$\{port}" ])) ''
Port to connect to.
If "$\{port}" dap resolves a free port.
This is intended to be used with `executable.args`.
'';
executable = {
command = helpers.mkNullOrOption types.str "Command that spawns the adapter.";
command = mkNullOrOption types.str "Command that spawns the adapter.";
args = helpers.mkNullOrOption (types.listOf types.str) "Command arguments.";
args = mkNullOrOption (types.listOf types.str) "Command arguments.";
detached = helpers.defaultNullOpts.mkBool true "Spawn the debug adapter in detached state.";
detached = lib.nixvim.defaultNullOpts.mkBool true "Spawn the debug adapter in detached state.";
cwd = helpers.mkNullOrOption types.str "Working directory.";
cwd = mkNullOrOption types.str "Working directory.";
};
options.maxRetries = helpers.defaultNullOpts.mkInt 14 ''
options.maxRetries = lib.nixvim.defaultNullOpts.mkInt 14 ''
Amount of times the client should attempt to connect before erroring out.
There is a 250ms delay between each retry.
'';
@ -77,7 +78,7 @@ rec {
mkAdapterOption =
name: type:
helpers.mkNullOrOption (with types; attrsOf (either str type)) ''
mkNullOrOption (with types; attrsOf (either str type)) ''
Debug adapters of `${name}` type.
The adapters can also be set to a function which takes three arguments:
@ -117,21 +118,20 @@ rec {
};
mkSignOption = default: desc: {
text = helpers.defaultNullOpts.mkStr default desc;
texthl = helpers.mkNullOrOption types.str "`texthl` for sign.";
linehl = helpers.mkNullOrOption types.str "`linehl` for sign.";
numhl = helpers.mkNullOrOption types.str "`numhl` for sign.";
text = lib.nixvim.defaultNullOpts.mkStr default desc;
texthl = mkNullOrOption types.str "`texthl` for sign.";
linehl = mkNullOrOption types.str "`linehl` for sign.";
numhl = mkNullOrOption types.str "`numhl` for sign.";
};
processAdapters =
type: adapters:
with builtins;
mapAttrs (
lib.mapAttrs (
_: adapter:
if isString adapter then
helpers.mkRaw adapter
if builtins.isString adapter then
lib.nixvim.mkRaw adapter
else
filterAttrs (n: _: n != "enrichConfig") (
lib.filterAttrs (n: _: n != "enrichConfig") (
adapter
// {
inherit type;