mirror of
https://github.com/NotAShelf/nvf.git
synced 2026-06-26 22:34:44 +00:00
Merge pull request #1642 from horriblename/dap-rework
Some checks failed
Set up binary cache / cachix (default) (push) Has been cancelled
Set up binary cache / cachix (maximal) (push) Has been cancelled
Set up binary cache / cachix (nix) (push) Has been cancelled
Treewide Checks / Validate flake (push) Has been cancelled
Treewide Checks / Check formatting (push) Has been cancelled
Treewide Checks / Check source tree for typos (push) Has been cancelled
Treewide Checks / Validate documentation builds (push) Has been cancelled
Treewide Checks / Validate documentation builds-1 (push) Has been cancelled
Treewide Checks / Validate documentation builds-2 (push) Has been cancelled
Treewide Checks / Validate documentation builds-3 (push) Has been cancelled
Treewide Checks / Validate hyperlinks in documentation sources (push) Has been cancelled
Treewide Checks / Validate Editorconfig conformance (push) Has been cancelled
Build and deploy documentation / Check latest commit (push) Has been cancelled
Build and deploy documentation / publish (push) Has been cancelled
Some checks failed
Set up binary cache / cachix (default) (push) Has been cancelled
Set up binary cache / cachix (maximal) (push) Has been cancelled
Set up binary cache / cachix (nix) (push) Has been cancelled
Treewide Checks / Validate flake (push) Has been cancelled
Treewide Checks / Check formatting (push) Has been cancelled
Treewide Checks / Check source tree for typos (push) Has been cancelled
Treewide Checks / Validate documentation builds (push) Has been cancelled
Treewide Checks / Validate documentation builds-1 (push) Has been cancelled
Treewide Checks / Validate documentation builds-2 (push) Has been cancelled
Treewide Checks / Validate documentation builds-3 (push) Has been cancelled
Treewide Checks / Validate hyperlinks in documentation sources (push) Has been cancelled
Treewide Checks / Validate Editorconfig conformance (push) Has been cancelled
Build and deploy documentation / Check latest commit (push) Has been cancelled
Build and deploy documentation / publish (push) Has been cancelled
DAP rework
This commit is contained in:
commit
b1b92ec251
16 changed files with 726 additions and 300 deletions
|
|
@ -46,7 +46,7 @@ in {
|
||||||
# Example:
|
# Example:
|
||||||
#
|
#
|
||||||
# vim.languages.typescript.lsp.servers = mkOption {
|
# vim.languages.typescript.lsp.servers = mkOption {
|
||||||
# type = renamedEnum
|
# type = enumWithRename
|
||||||
# "vim.languages.typescript.lsp.servers"
|
# "vim.languages.typescript.lsp.servers"
|
||||||
# ["typescript-language-server" "some-other-server"]
|
# ["typescript-language-server" "some-other-server"]
|
||||||
# { ts_ls = "typescript-language-server"; };
|
# { ts_ls = "typescript-language-server"; };
|
||||||
|
|
|
||||||
|
|
@ -396,5 +396,33 @@ in {
|
||||||
Linters can still be customized via `vim.diagnostics.nvim-lint.<name>.args`
|
Linters can still be customized via `vim.diagnostics.nvim-lint.<name>.args`
|
||||||
'')
|
'')
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# 2026-06-13
|
||||||
|
[
|
||||||
|
(mkRemovedOptionModule ["vim" "languages" "clang" "dap" "package"] ''
|
||||||
|
Please use `vim.debugger.nvim-dap.adapters.<debugger>.command` instead.
|
||||||
|
'')
|
||||||
|
(mkRemovedOptionModule ["vim" "languages" "zig" "dap" "package"] ''
|
||||||
|
Please use `vim.debugger.nvim-dap.adapters.<debugger>.command` instead.
|
||||||
|
'')
|
||||||
|
(mkRemovedOptionModule ["vim" "languages" "python" "dap" "package"] ''
|
||||||
|
Please use `vim.debugger.nvim-dap.adapters.<debugger>.command` instead.
|
||||||
|
Also see `vim.debugger.nvim-dap.configurations.python` if you want
|
||||||
|
to use a custom python/additional libraries as your debuggee
|
||||||
|
'')
|
||||||
|
(mkRemovedOptionModule ["vim" "languages" "odin" "dap" "package"] ''
|
||||||
|
Please use `vim.debugger.nvim-dap.adapters.<debugger>.command` instead.
|
||||||
|
'')
|
||||||
|
(mkRemovedOptionModule ["vim" "languages" "java" "dap" "package"] ''
|
||||||
|
Please use `vim.debugger.nvim-dap.adapters.<debugger>.command` instead.
|
||||||
|
'')
|
||||||
|
(mkRenamedOptionModule
|
||||||
|
["vim" "languages" "php" "dap" "xdebug" "adapter"]
|
||||||
|
["vim" "debugger" "nvim-dap" "adapters" "xdebug"])
|
||||||
|
(mkRemovedOptionModule ["vim" "languages" "php" "dap" "xdebug" "port"] ''
|
||||||
|
Please use a custom `vim.debugger.nvim-dap.configurations.php`
|
||||||
|
instead.
|
||||||
|
'')
|
||||||
|
]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,11 +4,13 @@
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
|
inherit (builtins) concatStringsSep;
|
||||||
inherit (lib.strings) optionalString;
|
inherit (lib.strings) optionalString;
|
||||||
inherit (lib.modules) mkIf mkMerge;
|
inherit (lib.modules) mkIf mkMerge;
|
||||||
inherit (lib.attrsets) mapAttrs;
|
inherit (lib.attrsets) mapAttrs mapAttrsToList;
|
||||||
inherit (lib.nvim.binds) mkKeymap;
|
inherit (lib.nvim.binds) mkKeymap;
|
||||||
inherit (lib.nvim.dag) entryAnywhere entryAfter;
|
inherit (lib.nvim.dag) entryAnywhere entryAfter;
|
||||||
|
inherit (lib.nvim.lua) toLuaObject;
|
||||||
|
|
||||||
cfg = config.vim.debugger.nvim-dap;
|
cfg = config.vim.debugger.nvim-dap;
|
||||||
opt = {
|
opt = {
|
||||||
|
|
@ -28,6 +30,30 @@ in {
|
||||||
nvim-dap = entryAnywhere ''
|
nvim-dap = entryAnywhere ''
|
||||||
local dap = require("dap")
|
local dap = require("dap")
|
||||||
vim.fn.sign_define("DapBreakpoint", { text = "🛑", texthl = "ErrorMsg", linehl = "", numhl = "" })
|
vim.fn.sign_define("DapBreakpoint", { text = "🛑", texthl = "ErrorMsg", linehl = "", numhl = "" })
|
||||||
|
|
||||||
|
local nvf_dap_input_cache= {}
|
||||||
|
local function nvf_dap_cached_input(cache_key, prompt, default, completion)
|
||||||
|
default = nvf_dap_input_cache[cache_key] or default
|
||||||
|
nvf_dap_input_cache[cache_key] =
|
||||||
|
vim.fn.input(prompt, default, completion)
|
||||||
|
return nvf_dap_input_cache[cache_key]
|
||||||
|
end
|
||||||
|
|
||||||
|
${
|
||||||
|
concatStringsSep "\n"
|
||||||
|
(mapAttrsToList (name: opts: ''
|
||||||
|
dap.adapters[${toLuaObject name}] = ${toLuaObject opts}
|
||||||
|
'')
|
||||||
|
cfg.adapters)
|
||||||
|
}
|
||||||
|
|
||||||
|
${
|
||||||
|
concatStringsSep "\n"
|
||||||
|
(mapAttrsToList (ft: opts: ''
|
||||||
|
dap.configurations[${toLuaObject ft}] = ${toLuaObject opts}
|
||||||
|
'')
|
||||||
|
cfg.configurations)
|
||||||
|
}
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
// mapAttrs (_: v: (entryAfter ["nvim-dap"] v)) cfg.sources;
|
// mapAttrs (_: v: (entryAfter ["nvim-dap"] v)) cfg.sources;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
|
./presets
|
||||||
./config.nix
|
./config.nix
|
||||||
./nvim-dap.nix
|
./nvim-dap.nix
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,254 @@
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (lib.options) mkEnableOption mkOption;
|
inherit (lib.options) mkEnableOption mkOption;
|
||||||
inherit (lib.types) bool attrsOf str;
|
inherit (lib.types) bool attrsOf str submodule anything either enum oneOf listOf nullOr int;
|
||||||
inherit (lib.nvim.types) mkPluginSetupOption;
|
inherit (lib.nvim.types) mkPluginSetupOption luaInline;
|
||||||
inherit (config.vim.lib) mkMappingOption;
|
inherit (config.vim.lib) mkMappingOption;
|
||||||
|
|
||||||
|
commonOptions = {
|
||||||
|
initialize_timeout_sec = mkOption {
|
||||||
|
type = nullOr int;
|
||||||
|
default = null;
|
||||||
|
defaultText = "4"; # plugin default
|
||||||
|
description = ''
|
||||||
|
How many seconds to wait for a response on an initialize request before
|
||||||
|
emitting a warning
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
disconnect_timeout_sec = mkOption {
|
||||||
|
type = nullOr int;
|
||||||
|
default = null;
|
||||||
|
defaultText = "3"; # plugin default
|
||||||
|
description = ''
|
||||||
|
How many seconds to wait for a disconnect response before
|
||||||
|
emitting a warning and closing the connection
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
source_filetype = mkOption {
|
||||||
|
type = nullOr str;
|
||||||
|
default = null;
|
||||||
|
description = ''
|
||||||
|
The filetype to use for content retrieved via a source request
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
# enrich_config accepted by all adapter types
|
||||||
|
enrich_config = mkOption {
|
||||||
|
type = nullOr luaInline;
|
||||||
|
default = null;
|
||||||
|
description = ''
|
||||||
|
Used to enrich a configurations with additional information.
|
||||||
|
See `:help dap-adapter`.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
execAdapterType = submodule {
|
||||||
|
options = {
|
||||||
|
type = mkOption {
|
||||||
|
type = enum ["executable"];
|
||||||
|
};
|
||||||
|
|
||||||
|
command = mkOption {
|
||||||
|
type = str;
|
||||||
|
description = "Command to invoke";
|
||||||
|
};
|
||||||
|
|
||||||
|
args = mkOption {
|
||||||
|
type = listOf str;
|
||||||
|
};
|
||||||
|
|
||||||
|
options =
|
||||||
|
commonOptions
|
||||||
|
// {
|
||||||
|
env = mkOption {
|
||||||
|
type = nullOr (attrsOf str);
|
||||||
|
default = null;
|
||||||
|
description = "Environment variables passed to the command";
|
||||||
|
};
|
||||||
|
|
||||||
|
cwd = mkOption {
|
||||||
|
type = nullOr str;
|
||||||
|
default = null;
|
||||||
|
description = "Set the working directory for the command";
|
||||||
|
};
|
||||||
|
|
||||||
|
detached = mkOption {
|
||||||
|
type = nullOr bool;
|
||||||
|
default = null;
|
||||||
|
defaultText = "true"; # plugin default
|
||||||
|
description = ''
|
||||||
|
Whether to spawn the debug adapter process in a detached state
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
id = mkOption {
|
||||||
|
type = nullOr str;
|
||||||
|
default = null;
|
||||||
|
description = ''
|
||||||
|
Identifier of the adapter. This is used for the `adapterId` property
|
||||||
|
of the initialize request.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
inherit enrich_config;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
serverPipeExecutable = submodule {
|
||||||
|
options = {
|
||||||
|
command = mkOption {
|
||||||
|
type = nullOr str;
|
||||||
|
description = "Command that spawns the debug adapter";
|
||||||
|
};
|
||||||
|
|
||||||
|
args = mkOption {
|
||||||
|
type = nullOr (listOf str);
|
||||||
|
default = null;
|
||||||
|
};
|
||||||
|
|
||||||
|
detached = mkOption {
|
||||||
|
type = nullOr bool;
|
||||||
|
default = null;
|
||||||
|
defaultText = "true"; # plugin default
|
||||||
|
description = ''
|
||||||
|
Whether to spawn the debug adapter process in a detached state
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
cwd = mkOption {
|
||||||
|
type = nullOr str;
|
||||||
|
default = null;
|
||||||
|
description = "Working directory";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
serverAdapterType = submodule {
|
||||||
|
options = {
|
||||||
|
type = mkOption {
|
||||||
|
type = enum ["server"];
|
||||||
|
};
|
||||||
|
|
||||||
|
host = mkOption {
|
||||||
|
type = nullOr str;
|
||||||
|
default = null;
|
||||||
|
defaultText = "127.0.0.1"; # plugin default
|
||||||
|
description = "Host to connect to";
|
||||||
|
};
|
||||||
|
|
||||||
|
port = mkOption {
|
||||||
|
type = either int (enum ["\${port}"]);
|
||||||
|
description = ''
|
||||||
|
Port to connect to. Use "''${port}" for a dynamically resolved free
|
||||||
|
port. This is intended to be used with executable.args.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
id = mkOption {
|
||||||
|
type = nullOr str;
|
||||||
|
default = null;
|
||||||
|
description = ''
|
||||||
|
Identifier of the adapter. This is used for the `adapterId` property
|
||||||
|
of the initialize request.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
executable = mkOption {
|
||||||
|
type = nullOr serverPipeExecutable;
|
||||||
|
default = null;
|
||||||
|
description = ''
|
||||||
|
Optional executable configuration to launch the debug adapter before
|
||||||
|
connecting via TCP
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
options =
|
||||||
|
commonOptions
|
||||||
|
// {
|
||||||
|
max_retries = mkOption {
|
||||||
|
type = nullOr int;
|
||||||
|
default = null;
|
||||||
|
defaultText = "14"; # plugin default
|
||||||
|
description = ''
|
||||||
|
Amount of times the client should attempt to connect before
|
||||||
|
erroring out (250ms delay between retries)
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
inherit enrich_config;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
pipeAdapterType = submodule {
|
||||||
|
options = {
|
||||||
|
type = mkOption {
|
||||||
|
type = enum ["pipe"];
|
||||||
|
};
|
||||||
|
|
||||||
|
pipe = mkOption {
|
||||||
|
type = str;
|
||||||
|
description = ''
|
||||||
|
Absolute path to the pipe file. Use \"''${pipe}\" for a dynamically
|
||||||
|
generated temporary filename
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
executable = mkOption {
|
||||||
|
type = nullOr serverPipeExecutable;
|
||||||
|
default = null;
|
||||||
|
description = ''
|
||||||
|
Optional executable configuration to launch the debug adapter before
|
||||||
|
connecting via pipe
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
options =
|
||||||
|
commonOptions
|
||||||
|
// {
|
||||||
|
timeout = mkOption {
|
||||||
|
type = nullOr int;
|
||||||
|
default = null;
|
||||||
|
defaultText = "5000"; # plugin default
|
||||||
|
description = ''
|
||||||
|
Max amount of time in ms to wait between spawning the
|
||||||
|
executable and connecting to the pipe
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
inherit enrich_config;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
configurationType = submodule {
|
||||||
|
freeformType = attrsOf anything;
|
||||||
|
# These 3 options are required, everything else is passed to the debug
|
||||||
|
# adapter
|
||||||
|
options = {
|
||||||
|
type = mkOption {
|
||||||
|
type = str;
|
||||||
|
description = "Which debug adapter to use";
|
||||||
|
};
|
||||||
|
|
||||||
|
request = mkOption {
|
||||||
|
type = enum ["attach" "launch"];
|
||||||
|
description = ''
|
||||||
|
Indicates whether the debug adapter should launch a debuggee or attach
|
||||||
|
to one that is already running.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
name = mkOption {
|
||||||
|
type = str;
|
||||||
|
description = "A user-readable name for the configuration";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
in {
|
in {
|
||||||
options.vim.debugger.nvim-dap = {
|
options.vim.debugger.nvim-dap = {
|
||||||
enable = mkEnableOption "debugging via nvim-dap";
|
enable = mkEnableOption "debugging via nvim-dap";
|
||||||
|
|
@ -19,7 +264,10 @@ in {
|
||||||
autoStart = mkOption {
|
autoStart = mkOption {
|
||||||
type = bool;
|
type = bool;
|
||||||
default = true;
|
default = true;
|
||||||
description = "Automatically Opens and Closes DAP-UI upon starting/closing a debugging session";
|
description = ''
|
||||||
|
Automatically Opens and Closes DAP-UI upon starting/closing a
|
||||||
|
debugging session
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -29,6 +277,27 @@ in {
|
||||||
type = attrsOf str;
|
type = attrsOf str;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
adapters = mkOption {
|
||||||
|
type = attrsOf (oneOf [
|
||||||
|
luaInline
|
||||||
|
execAdapterType
|
||||||
|
serverAdapterType
|
||||||
|
pipeAdapterType
|
||||||
|
]);
|
||||||
|
default = {};
|
||||||
|
description = "Adapter configurations. See `:help dap-adapter`";
|
||||||
|
};
|
||||||
|
|
||||||
|
configurations = mkOption {
|
||||||
|
type = attrsOf (listOf configurationType);
|
||||||
|
default = {};
|
||||||
|
description = ''
|
||||||
|
Mapping of filetype to list of debuggee configurations.
|
||||||
|
|
||||||
|
See `:help dap-configuration`.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
mappings = {
|
mappings = {
|
||||||
continue = mkMappingOption "Continue" "<leader>dc";
|
continue = mkMappingOption "Continue" "<leader>dc";
|
||||||
restart = mkMappingOption "Restart" "<leader>dR";
|
restart = mkMappingOption "Restart" "<leader>dR";
|
||||||
|
|
|
||||||
54
modules/plugins/debugger/nvim-dap/presets/debugpy.nix
Normal file
54
modules/plugins/debugger/nvim-dap/presets/debugpy.nix
Normal file
|
|
@ -0,0 +1,54 @@
|
||||||
|
{
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
config,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
|
inherit (lib.modules) mkIf;
|
||||||
|
inherit (lib.options) mkEnableOption;
|
||||||
|
inherit (lib.generators) mkLuaInline;
|
||||||
|
inherit (lib.meta) getExe;
|
||||||
|
|
||||||
|
cfg = config.vim.debugger.nvim-dap.presets.debugpy;
|
||||||
|
package = pkgs.python3.withPackages (ps: with ps; [debugpy]);
|
||||||
|
in {
|
||||||
|
options.vim.debugger.nvim-dap.presets.debugpy = {
|
||||||
|
enable = mkEnableOption ''
|
||||||
|
adapter configuration for debugpy.
|
||||||
|
Use {option}`vim.debugger.nvim-dap.adapters.debugpy` for customization.
|
||||||
|
|
||||||
|
A configuration is also needed for your filetype in
|
||||||
|
{option}`vim.debugger.nvim-dap.configurations`
|
||||||
|
See https://github.com/microsoft/debugpy/wiki/Debug-configuration-settings
|
||||||
|
for supported options.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
config.vim.debugger.nvim-dap.adapters = mkIf cfg.enable {
|
||||||
|
debugpy = mkLuaInline ''
|
||||||
|
function(cb, config)
|
||||||
|
if config.request == "attach" then
|
||||||
|
local port = (config.connect or config).port
|
||||||
|
local host = (config.connect or config).host or "127.0.0.1"
|
||||||
|
cb({
|
||||||
|
type = "server",
|
||||||
|
port = assert(port, "`connect.port` is required for a python `attach` configuration"),
|
||||||
|
host = host,
|
||||||
|
options = {
|
||||||
|
source_filetype = "python",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
else
|
||||||
|
cb({
|
||||||
|
type = "executable",
|
||||||
|
command = "${getExe package}",
|
||||||
|
args = { "-m", "debugpy.adapter" },
|
||||||
|
options = {
|
||||||
|
source_filetype = "python",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
||||||
8
modules/plugins/debugger/nvim-dap/presets/default.nix
Normal file
8
modules/plugins/debugger/nvim-dap/presets/default.nix
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
./debugpy.nix
|
||||||
|
./jls.nix
|
||||||
|
./lldb.nix
|
||||||
|
./xdebug.nix
|
||||||
|
];
|
||||||
|
}
|
||||||
31
modules/plugins/debugger/nvim-dap/presets/jls.nix
Normal file
31
modules/plugins/debugger/nvim-dap/presets/jls.nix
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
{
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
config,
|
||||||
|
inputs,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
|
inherit (lib.modules) mkIf;
|
||||||
|
inherit (lib.options) mkEnableOption;
|
||||||
|
inherit (lib.meta) getExe';
|
||||||
|
|
||||||
|
cfg = config.vim.debugger.nvim-dap.presets.jls;
|
||||||
|
pkg = inputs.self.packages.${pkgs.stdenv.hostPlatform.system}.jls;
|
||||||
|
in {
|
||||||
|
options.vim.debugger.nvim-dap.presets.jls = {
|
||||||
|
enable = mkEnableOption ''
|
||||||
|
adapter configuration for JLS.
|
||||||
|
Use {option}`vim.debugger.nvim-dap.adapters.jls` for customization.
|
||||||
|
|
||||||
|
A configuration is also needed for your filetype in
|
||||||
|
{option}`vim.debugger.nvim-dap.configurations`
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
config.vim.debugger.nvim-dap.adapters = mkIf cfg.enable {
|
||||||
|
jls = {
|
||||||
|
type = "executable";
|
||||||
|
command = getExe' pkg "jls-dap";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
28
modules/plugins/debugger/nvim-dap/presets/lldb.nix
Normal file
28
modules/plugins/debugger/nvim-dap/presets/lldb.nix
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
{
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
config,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
|
inherit (lib.modules) mkIf;
|
||||||
|
inherit (lib.options) mkEnableOption;
|
||||||
|
|
||||||
|
cfg = config.vim.debugger.nvim-dap.presets.lldb;
|
||||||
|
in {
|
||||||
|
options.vim.debugger.nvim-dap.presets.lldb = {
|
||||||
|
enable = mkEnableOption ''
|
||||||
|
adapter configuration for LLDB using `lldb-dap`.
|
||||||
|
Use {option}`vim.debugger.nvim-dap.adapters.lldb` for customization.
|
||||||
|
|
||||||
|
A configuration is also needed for your filetype in
|
||||||
|
{option}`vim.debugger.nvim-dap.configurations`
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
config.vim.debugger.nvim-dap.adapters = mkIf cfg.enable {
|
||||||
|
lldb = {
|
||||||
|
type = "executable";
|
||||||
|
command = "${pkgs.lldb}/bin/lldb-dap";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
32
modules/plugins/debugger/nvim-dap/presets/xdebug.nix
Normal file
32
modules/plugins/debugger/nvim-dap/presets/xdebug.nix
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
{
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
config,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
|
inherit (lib.modules) mkIf;
|
||||||
|
inherit (lib.options) mkEnableOption;
|
||||||
|
inherit (lib.meta) getExe;
|
||||||
|
|
||||||
|
cfg = config.vim.debugger.nvim-dap.presets.xdebug;
|
||||||
|
in {
|
||||||
|
options.vim.debugger.nvim-dap.presets.xdebug = {
|
||||||
|
enable = mkEnableOption ''
|
||||||
|
adapter configuration for Xdebug.
|
||||||
|
Use {option}`vim.debugger.nvim-dap.adapters.xdebug` for customization.
|
||||||
|
|
||||||
|
A configuration is also needed for your filetype in
|
||||||
|
{option}`vim.debugger.nvim-dap.configurations`
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
config.vim.debugger.nvim-dap.adapters = mkIf cfg.enable {
|
||||||
|
xdebug = {
|
||||||
|
type = "executable";
|
||||||
|
command = getExe pkgs.nodejs;
|
||||||
|
args = [
|
||||||
|
"${pkgs.vscode-extensions.xdebug.php-debug}/share/vscode/extensions/xdebug.php-debug/out/phpDebug.js"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -6,47 +6,42 @@
|
||||||
}: let
|
}: let
|
||||||
inherit (builtins) attrNames;
|
inherit (builtins) attrNames;
|
||||||
inherit (lib.options) mkEnableOption mkOption literalExpression;
|
inherit (lib.options) mkEnableOption mkOption literalExpression;
|
||||||
inherit (lib.types) bool enum package listOf;
|
inherit (lib.types) bool enum listOf;
|
||||||
inherit (lib) genAttrs;
|
inherit (lib) genAttrs;
|
||||||
inherit (lib.meta) getExe getExe';
|
inherit (lib.meta) getExe getExe';
|
||||||
inherit (lib.modules) mkIf mkMerge;
|
inherit (lib.modules) mkIf mkMerge;
|
||||||
inherit (lib.nvim.types) mkGrammarOption;
|
|
||||||
inherit (lib.generators) mkLuaInline;
|
inherit (lib.generators) mkLuaInline;
|
||||||
|
inherit (lib.nvim.types) mkGrammarOption;
|
||||||
inherit (lib.nvim.dag) entryAfter;
|
inherit (lib.nvim.dag) entryAfter;
|
||||||
inherit (lib.nvim.attrsets) mapListToAttrs;
|
inherit (lib.nvim.attrsets) mapListToAttrs;
|
||||||
|
inherit (lib.nvim.types) deprecatedSingleOrListOf enumWithRename;
|
||||||
|
|
||||||
cfg = config.vim.languages.clang;
|
cfg = config.vim.languages.clang;
|
||||||
|
|
||||||
defaultServers = ["clangd"];
|
defaultServers = ["clangd"];
|
||||||
servers = ["ccls" "clangd"];
|
servers = ["ccls" "clangd"];
|
||||||
|
|
||||||
defaultDebugger = "lldb-vscode";
|
defaultDebugger = ["lldb"];
|
||||||
debuggers = {
|
dapConfigurations = {
|
||||||
lldb-vscode = {
|
lldb = [
|
||||||
package = pkgs.lldb;
|
{
|
||||||
dapConfig = ''
|
name = "Launch";
|
||||||
dap.adapters.lldb = {
|
type = "lldb";
|
||||||
type = 'executable',
|
request = "launch";
|
||||||
command = '${cfg.dap.package}/bin/lldb-dap',
|
program = mkLuaInline ''
|
||||||
name = 'lldb'
|
function()
|
||||||
}
|
return nvf_dap_cached_input(
|
||||||
dap.configurations.cpp = {
|
'clang_lldb_launch_exe',
|
||||||
{
|
"Path to executable: ",
|
||||||
name = 'Launch',
|
vim.fn.getcwd() .. "/",
|
||||||
type = 'lldb',
|
"file")
|
||||||
request = 'launch',
|
end
|
||||||
program = function()
|
'';
|
||||||
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
|
cwd = "\${workspaceFolder}";
|
||||||
end,
|
stopOnEntry = false;
|
||||||
cwd = "''${workspaceFolder}",
|
args = [];
|
||||||
stopOnEntry = false,
|
}
|
||||||
args = {},
|
];
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
dap.configurations.c = dap.configurations.cpp
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
defaultFormat = ["clang-format"];
|
defaultFormat = ["clang-format"];
|
||||||
|
|
@ -147,14 +142,13 @@ in {
|
||||||
};
|
};
|
||||||
debugger = mkOption {
|
debugger = mkOption {
|
||||||
description = "clang debugger to use";
|
description = "clang debugger to use";
|
||||||
type = enum (attrNames debuggers);
|
type =
|
||||||
|
deprecatedSingleOrListOf "vim.languages.clang.dap.debugger"
|
||||||
|
(enumWithRename "vim.languages.clang.dap.debugger" (attrNames dapConfigurations) {
|
||||||
|
lldb-vscode = "lldb";
|
||||||
|
});
|
||||||
default = defaultDebugger;
|
default = defaultDebugger;
|
||||||
};
|
};
|
||||||
package = mkOption {
|
|
||||||
description = "clang debugger package.";
|
|
||||||
type = package;
|
|
||||||
default = debuggers.${cfg.dap.debugger}.package;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
format = {
|
format = {
|
||||||
|
|
@ -208,8 +202,16 @@ in {
|
||||||
})
|
})
|
||||||
|
|
||||||
(mkIf cfg.dap.enable {
|
(mkIf cfg.dap.enable {
|
||||||
vim.debugger.nvim-dap.enable = true;
|
vim.debugger.nvim-dap = let
|
||||||
vim.debugger.nvim-dap.sources.clang-debugger = debuggers.${cfg.dap.debugger}.dapConfig;
|
conf = mkMerge (map (name: dapConfigurations.${name}) cfg.dap.debugger);
|
||||||
|
in {
|
||||||
|
enable = true;
|
||||||
|
presets = genAttrs cfg.dap.debugger (_: {enable = true;});
|
||||||
|
configurations = {
|
||||||
|
c = conf;
|
||||||
|
cpp = conf;
|
||||||
|
};
|
||||||
|
};
|
||||||
})
|
})
|
||||||
|
|
||||||
(mkIf cfg.format.enable {
|
(mkIf cfg.format.enable {
|
||||||
|
|
|
||||||
|
|
@ -2,78 +2,73 @@
|
||||||
config,
|
config,
|
||||||
pkgs,
|
pkgs,
|
||||||
lib,
|
lib,
|
||||||
inputs,
|
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (lib.modules) mkIf mkMerge;
|
inherit (lib.modules) mkIf mkMerge;
|
||||||
inherit (lib.options) literalExpression mkEnableOption mkOption;
|
inherit (lib.options) literalExpression mkEnableOption mkOption;
|
||||||
inherit (lib.types) listOf str enum package;
|
inherit (lib.types) listOf str enum;
|
||||||
inherit (lib.attrsets) attrNames genAttrs;
|
inherit (lib.attrsets) attrNames genAttrs;
|
||||||
inherit (lib.meta) getExe getExe';
|
inherit (lib.lists) flatten;
|
||||||
inherit (lib.nvim.types) mkGrammarOption mkPluginSetupOption enumWithRename;
|
inherit (lib.meta) getExe;
|
||||||
|
inherit (lib.generators) mkLuaInline toPretty;
|
||||||
|
inherit (lib.nvim.types) mkGrammarOption mkPluginSetupOption deprecatedSingleOrListOf enumWithRename;
|
||||||
|
|
||||||
cfg = config.vim.languages.java;
|
cfg = config.vim.languages.java;
|
||||||
|
|
||||||
defaultServers = ["jdt-language-server"];
|
defaultServers = ["jdt-language-server"];
|
||||||
servers = ["jdt-language-server" "jls"];
|
servers = ["jdt-language-server" "jls"];
|
||||||
|
|
||||||
defaultDebugger = "jls";
|
defaultDebugger = ["jls"];
|
||||||
debuggers = {
|
dapConfigurations = {
|
||||||
jls = let
|
jls = [
|
||||||
pkg = inputs.self.packages.${pkgs.stdenv.hostPlatform.system}.jls;
|
{
|
||||||
in {
|
type = "jls";
|
||||||
package = pkg;
|
request = "attach";
|
||||||
config = ''
|
name = "Attach Auto";
|
||||||
dap.adapters.jls= {
|
hostName = "localhost";
|
||||||
type = 'executable',
|
port = 5005;
|
||||||
command = '${getExe' pkg "jls-dap"}',
|
sourceRoots = mkLuaInline ''
|
||||||
}
|
function()
|
||||||
dap.configurations.java = {
|
local matches = {}
|
||||||
{
|
|
||||||
type = "jls",
|
|
||||||
request = "attach",
|
|
||||||
name = "Attach Auto",
|
|
||||||
hostName = "localhost",
|
|
||||||
port = 5005,
|
|
||||||
sourceRoots = function()
|
|
||||||
local matches = {}
|
|
||||||
|
|
||||||
-- only look max 3 deep, due to performance reasons
|
-- only look max 3 deep, due to performance reasons
|
||||||
for _, pattern in ipairs({
|
for _, pattern in ipairs({
|
||||||
"src/main/java",
|
"src/main/java",
|
||||||
"*/src/main/java",
|
"*/src/main/java",
|
||||||
"*/*/src/main/java",
|
"*/*/src/main/java",
|
||||||
"*/*/*/src/main/java",
|
"*/*/*/src/main/java",
|
||||||
}) do
|
}) do
|
||||||
vim.list_extend(matches, vim.fn.glob(pattern, true, true))
|
vim.list_extend(matches, vim.fn.glob(pattern, true, true))
|
||||||
end
|
end
|
||||||
|
|
||||||
return matches
|
return matches
|
||||||
end,
|
end
|
||||||
},
|
'';
|
||||||
{
|
}
|
||||||
type = "jls",
|
{
|
||||||
request = "attach",
|
type = "jls";
|
||||||
name = "Attach Manual",
|
request = "attach";
|
||||||
hostName = "localhost",
|
name = "Attach Manual";
|
||||||
port = 5005,
|
hostName = "localhost";
|
||||||
sourceRoots = function()
|
port = 5005;
|
||||||
local path = vim.fn.input(
|
sourceRoots = mkLuaInline ''
|
||||||
"Path to src/main/java: ",
|
function()
|
||||||
vim.fn.getcwd() .. "/",
|
local path = nvf_dap_cached_input(
|
||||||
"dir"
|
"java_jls_attach_root",
|
||||||
)
|
"Path to src/main/java: ",
|
||||||
|
vim.fn.getcwd() .. "/",
|
||||||
|
"dir"
|
||||||
|
)
|
||||||
|
|
||||||
if path == "" then
|
if path == "" then
|
||||||
return {}
|
return {}
|
||||||
end
|
end
|
||||||
|
|
||||||
return { vim.fn.fnamemodify(path, ":p") }
|
return { vim.fn.fnamemodify(path, ":p") }
|
||||||
end,
|
end
|
||||||
},
|
'';
|
||||||
}
|
}
|
||||||
'';
|
];
|
||||||
};
|
|
||||||
};
|
};
|
||||||
in {
|
in {
|
||||||
options.vim.languages.java = {
|
options.vim.languages.java = {
|
||||||
|
|
@ -117,22 +112,28 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
debugger = mkOption {
|
debugger = mkOption {
|
||||||
type = enum (attrNames debuggers);
|
type =
|
||||||
|
deprecatedSingleOrListOf "vim.languages.java.dap.debugger"
|
||||||
|
(enum (attrNames dapConfigurations));
|
||||||
default = defaultDebugger;
|
default = defaultDebugger;
|
||||||
description = ''
|
description = ''
|
||||||
Java debugger to use.
|
Java debugger to use.
|
||||||
|
|
||||||
**JLS**
|
**JLS**
|
||||||
|
|
||||||
For `jls` to work, you need to run your application with debug symbols and networking.
|
For `jls` to work, you need to run your application with debug
|
||||||
|
symbols and networking.
|
||||||
|
|
||||||
The `jls` configuration is hardcoded to listen on port `5005`.
|
The `jls` configuration is hardcoded to listen on port `5005`. This
|
||||||
This matches the configuration described [upstream](https://github.com/idelice/jls#usage).
|
matches the configuration described
|
||||||
You can change this by modifying `vim.debugger.nvim-dap.sources.java-debugger`.
|
[upstream](https://github.com/idelice/jls#usage). You can change this
|
||||||
|
by modifying {option}`vim.debugger.nvim-dap.configurations.java`.
|
||||||
```nix
|
```nix
|
||||||
vim.debugger.nvim-dap.sources.java-debugger = /* lua */ '''
|
# mkForce can be omitted if you want to retain our default
|
||||||
${debuggers.jls.config}
|
# configurations
|
||||||
''';
|
vim.debugger.nvim-dap.configurations.java =
|
||||||
|
lib.mkForce
|
||||||
|
${toPretty {indent = " ";} dapConfigurations.jls};
|
||||||
```
|
```
|
||||||
|
|
||||||
*Examples:*
|
*Examples:*
|
||||||
|
|
@ -147,18 +148,13 @@ in {
|
||||||
java -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005 -jar your.jar
|
java -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005 -jar your.jar
|
||||||
```
|
```
|
||||||
- Springboot Maven:
|
- Springboot Maven:
|
||||||
For Springboot you can just pass the JVM args directly into the `spring-boot:run`.
|
For Springboot you can just pass the JVM args directly into the
|
||||||
|
`spring-boot:run`.
|
||||||
```sh
|
```sh
|
||||||
mvn spring-boot:run -Dspring-boot.run.jvmArguments="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005"
|
mvn spring-boot:run -Dspring-boot.run.jvmArguments="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005"
|
||||||
```
|
```
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
package = mkOption {
|
|
||||||
type = package;
|
|
||||||
default = debuggers.${cfg.dap.debugger}.package;
|
|
||||||
description = "Java debugger package.";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extensions = {
|
extensions = {
|
||||||
|
|
@ -218,7 +214,8 @@ in {
|
||||||
(mkIf cfg.dap.enable {
|
(mkIf cfg.dap.enable {
|
||||||
vim.debugger.nvim-dap = {
|
vim.debugger.nvim-dap = {
|
||||||
enable = true;
|
enable = true;
|
||||||
sources.java-debugger = debuggers.${cfg.dap.debugger}.config;
|
presets = genAttrs cfg.dap.debugger (_: {enable = true;});
|
||||||
|
configurations.java = flatten (map (name: dapConfigurations.${name}) cfg.dap.debugger);
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,27 +7,37 @@
|
||||||
inherit (builtins) attrNames;
|
inherit (builtins) attrNames;
|
||||||
inherit (lib.options) mkEnableOption mkOption literalExpression;
|
inherit (lib.options) mkEnableOption mkOption literalExpression;
|
||||||
inherit (lib.modules) mkIf mkMerge;
|
inherit (lib.modules) mkIf mkMerge;
|
||||||
inherit (lib.types) enum package listOf;
|
inherit (lib.types) enum listOf;
|
||||||
inherit (lib.nvim.dag) entryAfter;
|
inherit (lib.attrsets) genAttrs;
|
||||||
inherit (lib) genAttrs;
|
inherit (lib.lists) flatten;
|
||||||
inherit (lib.nvim.types) mkGrammarOption;
|
inherit (lib.generators) mkLuaInline;
|
||||||
|
inherit (lib.nvim.types) mkGrammarOption deprecatedSingleOrListOf enumWithRename;
|
||||||
|
|
||||||
cfg = config.vim.languages.odin;
|
cfg = config.vim.languages.odin;
|
||||||
|
|
||||||
defaultServers = ["ols"];
|
defaultServers = ["ols"];
|
||||||
servers = ["ols"];
|
servers = ["ols"];
|
||||||
defaultDebugger = "codelldb";
|
defaultDebugger = ["lldb"];
|
||||||
debuggers = {
|
dapConfigurations = {
|
||||||
codelldb = {
|
lldb = [
|
||||||
package = pkgs.lldb;
|
{
|
||||||
dapConfig = ''
|
name = "Launch";
|
||||||
dap.adapters.codelldb = {
|
type = "lldb";
|
||||||
type = 'executable',
|
request = "launch";
|
||||||
command = '${cfg.dap.package}/bin/lldb-dap',
|
program = mkLuaInline ''
|
||||||
name = 'codelldb'
|
function()
|
||||||
}
|
return nvf_dap_cached_input(
|
||||||
'';
|
'odin_lldb_launch_exe',
|
||||||
};
|
"Path to executable: ",
|
||||||
|
vim.fn.getcwd() .. "/",
|
||||||
|
"file")
|
||||||
|
end
|
||||||
|
'';
|
||||||
|
cwd = "\${workspaceFolder}";
|
||||||
|
stopOnEntry = false;
|
||||||
|
args = [];
|
||||||
|
}
|
||||||
|
];
|
||||||
};
|
};
|
||||||
in {
|
in {
|
||||||
options.vim.languages.odin = {
|
options.vim.languages.odin = {
|
||||||
|
|
@ -68,14 +78,13 @@ in {
|
||||||
|
|
||||||
debugger = mkOption {
|
debugger = mkOption {
|
||||||
description = "Odin debugger to use";
|
description = "Odin debugger to use";
|
||||||
type = enum (attrNames debuggers);
|
type =
|
||||||
default = defaultDebugger;
|
deprecatedSingleOrListOf "vim.languages.clang.dap.debugger"
|
||||||
};
|
(enumWithRename "vim.languages.clang.dap.debugger" (attrNames dapConfigurations) {
|
||||||
|
codelldb = "lldb";
|
||||||
|
});
|
||||||
|
|
||||||
package = mkOption {
|
default = defaultDebugger;
|
||||||
description = "Odin debugger package.";
|
|
||||||
type = package;
|
|
||||||
default = debuggers.${cfg.dap.debugger}.package;
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
@ -96,15 +105,10 @@ in {
|
||||||
})
|
})
|
||||||
|
|
||||||
(mkIf cfg.dap.enable {
|
(mkIf cfg.dap.enable {
|
||||||
vim = {
|
vim.debugger.nvim-dap = {
|
||||||
startPlugins = ["nvim-dap-odin"];
|
enable = true;
|
||||||
debugger.nvim-dap.sources.odin-debugger = debuggers.${cfg.dap.debugger}.dapConfig;
|
presets = genAttrs cfg.dap.debugger (_: {enable = true;});
|
||||||
pluginRC.nvim-dap-odin = entryAfter ["nvim-dap"] ''
|
configurations.odin = flatten (map (name: dapConfigurations.${name}) cfg.dap.debugger);
|
||||||
require('nvim-dap-odin').setup({
|
|
||||||
notifications = false -- contains no useful information
|
|
||||||
})
|
|
||||||
'';
|
|
||||||
debugger.nvim-dap.enable = true;
|
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
]);
|
]);
|
||||||
|
|
|
||||||
|
|
@ -7,10 +7,9 @@
|
||||||
inherit (builtins) attrNames;
|
inherit (builtins) attrNames;
|
||||||
inherit (lib.options) mkEnableOption mkOption literalExpression;
|
inherit (lib.options) mkEnableOption mkOption literalExpression;
|
||||||
inherit (lib) genAttrs;
|
inherit (lib) genAttrs;
|
||||||
inherit (lib.meta) getExe;
|
|
||||||
inherit (lib.modules) mkIf mkMerge;
|
inherit (lib.modules) mkIf mkMerge;
|
||||||
inherit (lib.types) enum int attrs listOf;
|
inherit (lib.types) enum listOf;
|
||||||
inherit (lib.nvim.lua) toLuaObject;
|
inherit (lib.lists) flatten;
|
||||||
inherit (lib.nvim.types) mkGrammarOption;
|
inherit (lib.nvim.types) mkGrammarOption;
|
||||||
inherit (lib.nvim.attrsets) mapListToAttrs;
|
inherit (lib.nvim.attrsets) mapListToAttrs;
|
||||||
|
|
||||||
|
|
@ -36,6 +35,20 @@
|
||||||
|
|
||||||
defaultDiagnosticsProvider = ["phpstan"];
|
defaultDiagnosticsProvider = ["phpstan"];
|
||||||
diagnosticsProviders = ["phpstan"];
|
diagnosticsProviders = ["phpstan"];
|
||||||
|
|
||||||
|
defaultDebugger = ["xdebug"];
|
||||||
|
dapConfigurations = {
|
||||||
|
xdebug = let
|
||||||
|
port = 9003;
|
||||||
|
in [
|
||||||
|
{
|
||||||
|
type = "xdebug";
|
||||||
|
request = "launch";
|
||||||
|
name = "Listen for XDebug at port ${toString port}";
|
||||||
|
inherit port;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
in {
|
in {
|
||||||
options.vim.languages.php = {
|
options.vim.languages.php = {
|
||||||
enable = mkEnableOption "PHP language support";
|
enable = mkEnableOption "PHP language support";
|
||||||
|
|
@ -87,23 +100,11 @@ in {
|
||||||
default = config.vim.languages.enableDAP;
|
default = config.vim.languages.enableDAP;
|
||||||
defaultText = literalExpression "config.vim.languages.enableDAP";
|
defaultText = literalExpression "config.vim.languages.enableDAP";
|
||||||
};
|
};
|
||||||
xdebug = {
|
|
||||||
adapter = mkOption {
|
debugger = mkOption {
|
||||||
type = attrs;
|
type = listOf (enum (attrNames dapConfigurations));
|
||||||
default = {
|
default = defaultDebugger;
|
||||||
type = "executable";
|
description = "PHP debugger to use";
|
||||||
command = getExe pkgs.nodejs;
|
|
||||||
args = [
|
|
||||||
"${pkgs.vscode-extensions.xdebug.php-debug}/share/vscode/extensions/xdebug.php-debug/out/phpDebug.js"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
description = "XDebug adapter to use for nvim-dap";
|
|
||||||
};
|
|
||||||
port = mkOption {
|
|
||||||
type = int;
|
|
||||||
default = 9003;
|
|
||||||
description = "Port to use for XDebug";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -154,21 +155,10 @@ in {
|
||||||
})
|
})
|
||||||
|
|
||||||
(mkIf cfg.dap.enable {
|
(mkIf cfg.dap.enable {
|
||||||
vim = {
|
vim.debugger.nvim-dap = {
|
||||||
debugger.nvim-dap = {
|
enable = true;
|
||||||
enable = true;
|
presets = genAttrs cfg.dap.debugger (_: {enable = true;});
|
||||||
sources.php-debugger = ''
|
configurations.php = flatten (map (name: dapConfigurations.${name}) cfg.dap.debugger);
|
||||||
dap.adapters.xdebug = ${toLuaObject cfg.dap.xdebug.adapter}
|
|
||||||
dap.configurations.php = {
|
|
||||||
{
|
|
||||||
type = 'xdebug',
|
|
||||||
request = 'launch',
|
|
||||||
name = 'Listen for XDebug',
|
|
||||||
port = ${toString cfg.dap.xdebug.port},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@
|
||||||
inherit (lib.meta) getExe;
|
inherit (lib.meta) getExe;
|
||||||
inherit (lib.modules) mkIf mkMerge;
|
inherit (lib.modules) mkIf mkMerge;
|
||||||
inherit (lib.types) enum package bool listOf;
|
inherit (lib.types) enum package bool listOf;
|
||||||
|
inherit (lib.generators) mkLuaInline;
|
||||||
inherit (lib.nvim.attrsets) mapListToAttrs;
|
inherit (lib.nvim.attrsets) mapListToAttrs;
|
||||||
inherit (lib.nvim.types) deprecatedSingleOrListOf;
|
inherit (lib.nvim.types) deprecatedSingleOrListOf;
|
||||||
inherit (lib.trivial) warn;
|
inherit (lib.trivial) warn;
|
||||||
|
|
@ -49,67 +50,34 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
defaultDebugger = "debugpy";
|
defaultDebugger = ["debugpy"];
|
||||||
debuggers = {
|
dapConfigurations = {
|
||||||
debugpy = {
|
debugpy = [
|
||||||
# idk if this is the best way to install/run debugpy
|
{
|
||||||
package = pkgs.python3.withPackages (ps: with ps; [debugpy]);
|
type = "debugpy";
|
||||||
dapConfig = ''
|
request = "launch";
|
||||||
dap.adapters.debugpy = function(cb, config)
|
name = "Launch file";
|
||||||
if config.request == 'attach' then
|
|
||||||
---@diagnostic disable-next-line: undefined-field
|
program = "\${file}";
|
||||||
local port = (config.connect or config).port
|
pythonPath = mkLuaInline ''
|
||||||
---@diagnostic disable-next-line: undefined-field
|
function()
|
||||||
local host = (config.connect or config).host or '127.0.0.1'
|
-- debugpy supports launching an application with a different interpreter then the one used to launch debugpy itself.
|
||||||
cb({
|
-- The code below looks for a `venv` or `.venv` folder in the current directly and uses the python within.
|
||||||
type = 'server',
|
-- You could adapt this - to for example use the `VIRTUAL_ENV` environment variable.
|
||||||
port = assert(port, '`connect.port` is required for a python `attach` configuration'),
|
local cwd = vim.fn.getcwd()
|
||||||
host = host,
|
if vim.fn.executable(cwd .. "/venv/bin/python") == 1 then
|
||||||
options = {
|
return cwd .. "/venv/bin/python"
|
||||||
source_filetype = 'python',
|
elseif vim.fn.executable(cwd .. "/.venv/bin/python") == 1 then
|
||||||
},
|
return cwd .. "/.venv/bin/python"
|
||||||
})
|
elseif vim.fn.executable("python") == 1 then
|
||||||
else
|
return vim.fn.exepath("python")
|
||||||
cb({
|
else -- this uses the same python package as the debugger
|
||||||
type = 'executable',
|
return nil
|
||||||
command = '${getExe cfg.dap.package}',
|
end
|
||||||
args = { '-m', 'debugpy.adapter' },
|
|
||||||
options = {
|
|
||||||
source_filetype = 'python',
|
|
||||||
},
|
|
||||||
})
|
|
||||||
end
|
end
|
||||||
end
|
'';
|
||||||
|
}
|
||||||
dap.configurations.python = {
|
];
|
||||||
{
|
|
||||||
-- The first three options are required by nvim-dap
|
|
||||||
type = 'debugpy'; -- the type here established the link to the adapter definition: `dap.adapters.debugpy`
|
|
||||||
request = 'launch';
|
|
||||||
name = "Launch file";
|
|
||||||
|
|
||||||
-- Options below are for debugpy, see https://github.com/microsoft/debugpy/wiki/Debug-configuration-settings for supported options
|
|
||||||
|
|
||||||
program = "''${file}"; -- This configuration will launch the current file if used.
|
|
||||||
pythonPath = function()
|
|
||||||
-- debugpy supports launching an application with a different interpreter then the one used to launch debugpy itself.
|
|
||||||
-- The code below looks for a `venv` or `.venv` folder in the current directly and uses the python within.
|
|
||||||
-- You could adapt this - to for example use the `VIRTUAL_ENV` environment variable.
|
|
||||||
local cwd = vim.fn.getcwd()
|
|
||||||
if vim.fn.executable(cwd .. '/venv/bin/python') == 1 then
|
|
||||||
return cwd .. '/venv/bin/python'
|
|
||||||
elseif vim.fn.executable(cwd .. '/.venv/bin/python') == 1 then
|
|
||||||
return cwd .. '/.venv/bin/python'
|
|
||||||
elseif vim.fn.executable("python") == 1 then
|
|
||||||
return vim.fn.exepath("python")
|
|
||||||
else -- WARNING cfg.dap.package probably has NO libraries other than builtins and debugpy
|
|
||||||
return '${getExe cfg.dap.package}'
|
|
||||||
end
|
|
||||||
end;
|
|
||||||
},
|
|
||||||
}
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
defaultDiagnosticsProvider = ["mypy"];
|
defaultDiagnosticsProvider = ["mypy"];
|
||||||
diagnosticsProviders = ["mypy"];
|
diagnosticsProviders = ["mypy"];
|
||||||
|
|
@ -171,20 +139,10 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
debugger = mkOption {
|
debugger = mkOption {
|
||||||
type = enum (attrNames debuggers);
|
type = deprecatedSingleOrListOf "vim.languages.python.dap.debugger" (enum (attrNames dapConfigurations));
|
||||||
default = defaultDebugger;
|
default = defaultDebugger;
|
||||||
description = "Python debugger to use";
|
description = "Python debugger to use";
|
||||||
};
|
};
|
||||||
|
|
||||||
package = mkOption {
|
|
||||||
type = package;
|
|
||||||
default = debuggers.${cfg.dap.debugger}.package;
|
|
||||||
example = literalExpression "with pkgs; python39.withPackages (ps: with ps; [debugpy])";
|
|
||||||
description = ''
|
|
||||||
Python debugger package.
|
|
||||||
This is a python package with debugpy installed, see https://nixos.wiki/wiki/Python#Install_Python_Packages.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extraDiagnostics = {
|
extraDiagnostics = {
|
||||||
|
|
@ -250,8 +208,11 @@ in {
|
||||||
})
|
})
|
||||||
|
|
||||||
(mkIf cfg.dap.enable {
|
(mkIf cfg.dap.enable {
|
||||||
vim.debugger.nvim-dap.enable = true;
|
vim.debugger.nvim-dap = {
|
||||||
vim.debugger.nvim-dap.sources.python-debugger = debuggers.${cfg.dap.debugger}.dapConfig;
|
enable = true;
|
||||||
|
presets = genAttrs cfg.dap.debugger (_: {enable = true;});
|
||||||
|
configurations.python = flatten (map (name: dapConfigurations.${name}) cfg.dap.debugger);
|
||||||
|
};
|
||||||
})
|
})
|
||||||
|
|
||||||
(mkIf cfg.extraDiagnostics.enable {
|
(mkIf cfg.extraDiagnostics.enable {
|
||||||
|
|
|
||||||
|
|
@ -7,43 +7,39 @@
|
||||||
inherit (builtins) attrNames;
|
inherit (builtins) attrNames;
|
||||||
inherit (lib.options) mkEnableOption mkOption literalExpression;
|
inherit (lib.options) mkEnableOption mkOption literalExpression;
|
||||||
inherit (lib.modules) mkIf mkMerge mkDefault;
|
inherit (lib.modules) mkIf mkMerge mkDefault;
|
||||||
inherit (lib) genAttrs;
|
inherit (lib.generators) mkLuaInline;
|
||||||
inherit (lib.types) bool package enum listOf;
|
inherit (lib.attrsets) genAttrs;
|
||||||
inherit (lib.nvim.types) mkGrammarOption;
|
inherit (lib.lists) flatten;
|
||||||
|
inherit (lib.types) bool enum listOf;
|
||||||
|
inherit (lib.nvim.types) mkGrammarOption deprecatedSingleOrListOf enumWithRename;
|
||||||
|
|
||||||
cfg = config.vim.languages.zig;
|
cfg = config.vim.languages.zig;
|
||||||
|
|
||||||
defaultServers = ["zls"];
|
defaultServers = ["zls"];
|
||||||
servers = ["zls"];
|
servers = ["zls"];
|
||||||
|
|
||||||
# TODO: dap.adapter.lldb is duplicated when enabling the
|
defaultDebugger = ["lldb"];
|
||||||
# vim.languages.clang.dap module. This does not cause
|
dapConfigurations = {
|
||||||
# breakage... but could be cleaner.
|
lldb = [
|
||||||
defaultDebugger = "lldb-vscode";
|
{
|
||||||
debuggers = {
|
name = "Launch";
|
||||||
lldb-vscode = {
|
type = "lldb";
|
||||||
package = pkgs.lldb;
|
request = "launch";
|
||||||
dapConfig = ''
|
program = mkLuaInline ''
|
||||||
dap.adapters.lldb = {
|
function()
|
||||||
type = 'executable',
|
return nvf_dap_cached_input(
|
||||||
command = '${cfg.dap.package}/bin/lldb-dap',
|
'zig_lldb_launch_exe',
|
||||||
name = 'lldb'
|
'Path to executable: ',
|
||||||
}
|
vim.fn.getcwd() .. '/',
|
||||||
dap.configurations.zig = {
|
'file'
|
||||||
{
|
)
|
||||||
name = 'Launch',
|
end
|
||||||
type = 'lldb',
|
'';
|
||||||
request = 'launch',
|
cwd = "\${workspaceFolder}";
|
||||||
program = function()
|
stopOnEntry = false;
|
||||||
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
|
args = [];
|
||||||
end,
|
}
|
||||||
cwd = "''${workspaceFolder}",
|
];
|
||||||
stopOnEntry = false,
|
|
||||||
args = {},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
in {
|
in {
|
||||||
options.vim.languages.zig = {
|
options.vim.languages.zig = {
|
||||||
|
|
@ -83,16 +79,14 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
debugger = mkOption {
|
debugger = mkOption {
|
||||||
type = enum (attrNames debuggers);
|
type =
|
||||||
|
deprecatedSingleOrListOf "vim.languages.zig.dap.debugger"
|
||||||
|
(enumWithRename "vim.languages.zig.dap.debugger" (attrNames dapConfigurations) {
|
||||||
|
lldb-vscode = "lldb";
|
||||||
|
});
|
||||||
default = defaultDebugger;
|
default = defaultDebugger;
|
||||||
description = "Zig debugger to use";
|
description = "Zig debugger to use";
|
||||||
};
|
};
|
||||||
|
|
||||||
package = mkOption {
|
|
||||||
type = package;
|
|
||||||
default = debuggers.${cfg.dap.debugger}.package;
|
|
||||||
description = "Zig debugger package.";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -119,9 +113,10 @@ in {
|
||||||
})
|
})
|
||||||
|
|
||||||
(mkIf cfg.dap.enable {
|
(mkIf cfg.dap.enable {
|
||||||
vim = {
|
vim.debugger.nvim-dap = {
|
||||||
debugger.nvim-dap.enable = true;
|
enable = true;
|
||||||
debugger.nvim-dap.sources.zig-debugger = debuggers.${cfg.dap.debugger}.dapConfig;
|
presets = genAttrs cfg.dap.debugger (_: {enable = true;});
|
||||||
|
configurations.zig = flatten (map (name: dapConfigurations.${name}) cfg.dap.debugger);
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
]);
|
]);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue