feat: add dap (debugging) config

main
Ian Mancini 2 years ago
parent b01bdc6734
commit 52a60ebfd9

@ -0,0 +1,111 @@
local dap = require("dap")
require("dap").adapters["pwa-node"] = {
type = "server",
host = "localhost",
port = "${port}",
executable = {
command = vim.env.HOME .. "/.asdf/installs/nodejs/lts/bin/node",
args = {
vim.fn.stdpath("data") .. "/mason/packages/js-debug-adapter/js-debug/src/dapDebugServer.js",
"${port}",
},
},
}
for _, language in ipairs({ "typescript", "javascript" }) do
dap.configurations[language] = {
{
type = "pwa-node",
request = "launch",
name = "Launch file",
program = "${file}",
cwd = "${workspaceFolder}",
},
{
type = "pwa-node",
request = "attach",
name = "Attach",
processId = require("dap.utils").pick_process,
cwd = "${workspaceFolder}",
},
{
type = "pwa-node",
request = "launch",
name = "Debug Jest Tests",
-- trace = true, -- include debugger info
runtimeExecutable = "node",
runtimeArgs = {
"./node_modules/jest/bin/jest.js",
"--runInBand",
},
rootPath = "${workspaceFolder}",
cwd = "${workspaceFolder}",
console = "integratedTerminal",
internalConsoleOptions = "neverOpen",
},
}
end
require("dapui").setup()
local wk = require("which-key")
wk.register({
d = {
name = "Debug",
d = {
function()
require("dapui").toggle()
end,
"Toggle debugger UI",
},
b = {
function()
require("dap").toggle_breakpoint()
end,
"Toggle breakpoint",
},
c = {
function()
require("dap").continue()
end,
"Launch or resume session",
},
o = {
function()
require("dap").step_over()
end,
"Step over",
},
i = {
function()
require("dap").step_into()
end,
"Step into",
},
p = {
function()
local config_dir = vim.loop.cwd() .. "/.vscode"
local config_file = config_dir .. "/launch.json"
if not vim.fn.filereadable(config_file) then
vim.ui.input(
{ prompt = "Debugger config not found at " .. config_file .. ". Create? [Y/n]" },
function(input)
if input == "" or input == "y" or input == "Y" then
vim.fn.mkdir(config_dir)
end
end
)
end
if vim.fn.filereadable(config_file) then
vim.cmd("edit " .. config_file)
end
end,
"Open project config",
},
},
}, {
prefix = "<leader>",
})

@ -285,9 +285,13 @@ return require("packer").startup(function()
use({ "Eduruiz/vim-blade" }) use({ "Eduruiz/vim-blade" })
-- DAP -- DAP
use("mfussenegger/nvim-dap") use({
use("Pocco81/dap-buddy.nvim") "mfussenegger/nvim-dap",
use("rcarriga/nvim-dap-ui") {
"rcarriga/nvim-dap-ui",
config = [[require('plugins.debugging')]],
},
})
-- Test runner -- Test runner
use({ use({

@ -13,6 +13,7 @@ require("mason-tool-installer").setup({
"prettierd", "prettierd",
"flake8", "flake8",
"black", "black",
"js-debug-adapter",
}, },
}) })

Loading…
Cancel
Save