Nvim: add dap configurations for Java/JavaScript/TypeScript
This commit is contained in:
parent
7e33569675
commit
917491744b
1 changed files with 97 additions and 17 deletions
|
@ -1,4 +1,6 @@
|
||||||
-- Debug adapter for NeoVim
|
-- Debug adapter for NeoVim
|
||||||
|
|
||||||
|
local masonPkg = vim.fn.stdpath("data") .. "/mason/packages"
|
||||||
--- @type LazyPluginSpec
|
--- @type LazyPluginSpec
|
||||||
return {
|
return {
|
||||||
"mfussenegger/nvim-dap",
|
"mfussenegger/nvim-dap",
|
||||||
|
@ -7,22 +9,35 @@ return {
|
||||||
},
|
},
|
||||||
config = function()
|
config = function()
|
||||||
local dap = require("dap")
|
local dap = require("dap")
|
||||||
|
local configurations = dap.configurations
|
||||||
|
local adapters = dap.adapters
|
||||||
|
local pick_process = require("dap.utils").pick_process
|
||||||
|
|
||||||
dap.adapters.bashdb = {
|
-- 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
|
||||||
|
|
||||||
|
-- Bash/sh
|
||||||
|
local bashAdapter = masonPkg .. "/bash-debug-adapter"
|
||||||
|
local bashExtension = bashAdapter .. "/extension"
|
||||||
|
adapters.bashdb = {
|
||||||
type = "executable",
|
type = "executable",
|
||||||
command = vim.fn.stdpath("data") .. "/mason/packages/bash-debug-adapter/bash-debug-adapter",
|
command = bashAdapter .. "/bash-debug-adapter",
|
||||||
name = "bashdb",
|
name = "bashdb",
|
||||||
}
|
}
|
||||||
|
configurations.sh = {
|
||||||
dap.configurations.sh = {
|
name = "Debug with bashdb",
|
||||||
{
|
|
||||||
type = "bashdb",
|
type = "bashdb",
|
||||||
request = "launch",
|
request = "launch",
|
||||||
name = "Launch file",
|
|
||||||
showDebugOutput = true,
|
showDebugOutput = true,
|
||||||
pathBashdb = vim.fn.stdpath("data") .. "/mason/packages/bash-debug-adapter/extension/bashdb_dir/bashdb",
|
|
||||||
pathBashdbLib = vim.fn.stdpath("data") .. "/mason/packages/bash-debug-adapter/extension/bashdb_dir",
|
|
||||||
trace = true,
|
trace = true,
|
||||||
|
pathBashdbLib = bashExtension .. "/bashdb_dir",
|
||||||
|
pathBashdb = bashExtension .. "/bashdb_dir/bashdb",
|
||||||
file = "${file}",
|
file = "${file}",
|
||||||
program = "${file}",
|
program = "${file}",
|
||||||
cwd = "${workspaceFolder}",
|
cwd = "${workspaceFolder}",
|
||||||
|
@ -33,6 +48,71 @@ return {
|
||||||
args = {},
|
args = {},
|
||||||
env = {},
|
env = {},
|
||||||
terminalKind = "integrated",
|
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" },
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
--- @type Configuration[]
|
||||||
|
local browserConfigs = {
|
||||||
|
{
|
||||||
|
name = "LibreWolf attach",
|
||||||
|
type = "libreWolf",
|
||||||
|
request = "attach",
|
||||||
|
url = "http://localhost:4000",
|
||||||
|
webRoot = "${workspaceFolder}",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
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",
|
||||||
|
request = "launch",
|
||||||
|
program = "${file}",
|
||||||
|
cwd = "${workspaceFolder}",
|
||||||
|
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,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
end,
|
end,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue