2023-11-25 14:37:36 +02:00
|
|
|
-- Debug adapter for NeoVim
|
2023-11-29 21:30:21 +02:00
|
|
|
|
|
|
|
local masonPkg = vim.fn.stdpath("data") .. "/mason/packages"
|
2023-11-25 14:37:36 +02:00
|
|
|
--- @type LazyPluginSpec
|
2023-11-18 02:27:14 +02:00
|
|
|
return {
|
|
|
|
"mfussenegger/nvim-dap",
|
2023-11-25 21:25:23 +02:00
|
|
|
dependencies = {
|
|
|
|
{ "rcarriga/nvim-dap-ui", config = true },
|
|
|
|
},
|
2023-11-18 02:27:14 +02:00
|
|
|
config = function()
|
|
|
|
local dap = require("dap")
|
2023-11-29 21:30:21 +02:00
|
|
|
local configurations = dap.configurations
|
|
|
|
local adapters = dap.adapters
|
|
|
|
local pick_process = require("dap.utils").pick_process
|
|
|
|
|
|
|
|
-- Applies all given configurations to the given filetypes
|
|
|
|
--- @param filetypes string[]
|
|
|
|
--- @param configs Configuration[]
|
|
|
|
local function dapConfigure(filetypes, configs)
|
|
|
|
for _, ft in ipairs(filetypes) do
|
|
|
|
configurations[ft] = configs
|
|
|
|
end
|
|
|
|
end
|
2023-02-22 17:54:39 +02:00
|
|
|
|
2023-11-29 21:30:21 +02:00
|
|
|
-- Bash/sh
|
|
|
|
local bashAdapter = masonPkg .. "/bash-debug-adapter"
|
|
|
|
local bashExtension = bashAdapter .. "/extension"
|
|
|
|
adapters.bashdb = {
|
2023-11-18 02:27:14 +02:00
|
|
|
type = "executable",
|
2023-11-29 21:30:21 +02:00
|
|
|
command = bashAdapter .. "/bash-debug-adapter",
|
2023-11-18 02:27:14 +02:00
|
|
|
name = "bashdb",
|
|
|
|
}
|
2023-11-29 21:30:21 +02:00
|
|
|
configurations.sh = {
|
|
|
|
name = "Debug with bashdb",
|
|
|
|
type = "bashdb",
|
|
|
|
request = "launch",
|
|
|
|
showDebugOutput = true,
|
|
|
|
trace = true,
|
|
|
|
pathBashdbLib = bashExtension .. "/bashdb_dir",
|
|
|
|
pathBashdb = bashExtension .. "/bashdb_dir/bashdb",
|
|
|
|
file = "${file}",
|
|
|
|
program = "${file}",
|
|
|
|
cwd = "${workspaceFolder}",
|
|
|
|
pathCat = "cat",
|
|
|
|
pathBash = "/bin/bash",
|
|
|
|
pathMkfifo = "mkfifo",
|
|
|
|
pathPkill = "pkill",
|
|
|
|
args = {},
|
|
|
|
env = {},
|
|
|
|
terminalKind = "integrated",
|
|
|
|
}
|
|
|
|
|
|
|
|
-- JavaScript/TypeScript in Firefox/Chrome/Node
|
|
|
|
adapters.libreWolf = {
|
|
|
|
type = "executable",
|
|
|
|
command = "node",
|
|
|
|
args = { masonPkg .. "/firefox-debug-adapter/dist/adapter.bundle.js" },
|
|
|
|
}
|
|
|
|
adapters["pwa-node"] = {
|
|
|
|
type = "server",
|
|
|
|
host = "localhost",
|
|
|
|
port = "${port}",
|
|
|
|
executable = {
|
|
|
|
command = "node",
|
|
|
|
args = { masonPkg .. "/js-debug-adapter/js-debug/src/dapDebugServer.js", "8123" },
|
|
|
|
},
|
|
|
|
}
|
2023-02-22 17:54:39 +02:00
|
|
|
|
2023-11-29 21:30:21 +02:00
|
|
|
--- @type Configuration[]
|
|
|
|
local browserConfigs = {
|
|
|
|
{
|
|
|
|
name = "LibreWolf attach",
|
|
|
|
type = "libreWolf",
|
|
|
|
request = "attach",
|
|
|
|
url = "http://localhost:4000",
|
|
|
|
webRoot = "${workspaceFolder}",
|
|
|
|
},
|
2023-11-18 02:27:14 +02:00
|
|
|
{
|
2023-11-29 21:30:21 +02:00
|
|
|
name = "Chrome attach",
|
|
|
|
type = "pwa-chrome",
|
|
|
|
request = "attach",
|
|
|
|
cwd = "${workspaceFolder}",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
--- @type Configuration[]
|
|
|
|
local nodeConfigs = {
|
|
|
|
{
|
|
|
|
name = "Node attach",
|
|
|
|
type = "pwa-node",
|
|
|
|
request = "attach",
|
|
|
|
processId = pick_process,
|
|
|
|
cwd = "${workspaceFolder}",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name = "Node launch",
|
|
|
|
type = "pwa-node",
|
2023-11-18 02:27:14 +02:00
|
|
|
request = "launch",
|
|
|
|
program = "${file}",
|
|
|
|
cwd = "${workspaceFolder}",
|
2023-11-29 21:30:21 +02:00
|
|
|
port = "8123",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
dapConfigure({ "typescriptreact", "javascriptreact" }, browserConfigs)
|
|
|
|
dapConfigure({ "typescript", "javascript" }, vim.tbl_extend("force", browserConfigs, nodeConfigs))
|
|
|
|
|
|
|
|
-- Java
|
|
|
|
configurations.java = {
|
|
|
|
{
|
|
|
|
name = "Debug (Attach) - Remote",
|
|
|
|
type = "java",
|
|
|
|
request = "attach",
|
|
|
|
hostName = "127.0.0.1",
|
|
|
|
port = 9009,
|
2023-11-18 02:27:14 +02:00
|
|
|
},
|
|
|
|
}
|
|
|
|
end,
|
|
|
|
}
|