feat(nvim): js/ts debugging

This commit is contained in:
Sergio Laín 2023-10-19 13:26:02 +02:00
parent d27b06709c
commit f60979981c
No known key found for this signature in database
GPG key ID: 14C9B8080681777B
3 changed files with 63 additions and 0 deletions

View file

@ -32,6 +32,7 @@ return {
"gomodifytags",
"isort",
"stylelint",
"js-debug-adapter",
},
},
},

View file

@ -0,0 +1,9 @@
return {
{
"Wansmer/treesj",
keys = {
{ "J", "<cmd>TSJToggle<cr>", desc = "Join Toggle" },
},
opts = { use_default_keymaps = false, max_join_length = 150 },
},
}

View file

@ -0,0 +1,53 @@
return {
{
"mfussenegger/nvim-dap",
dependencies = {
{
"williamboman/mason.nvim",
opts = function(_, opts)
opts.ensure_installed = opts.ensure_installed or {}
table.insert(opts.ensure_installed, "js-debug-adapter")
end,
},
},
opts = function()
local dap = require("dap")
if not dap.adapters["pwa-node"] then
require("dap").adapters["pwa-node"] = {
type = "server",
host = "localhost",
port = "${port}",
executable = {
command = "node",
-- 💀 Make sure to update this path to point to your installation
args = {
require("mason-registry").get_package("js-debug-adapter"):get_install_path()
.. "/js-debug/src/dapDebugServer.js",
"${port}",
},
},
}
end
for _, language in ipairs({ "typescript", "javascript", "typescriptreact", "javascriptreact" }) do
if not dap.configurations[language] then
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}",
},
}
end
end
end,
},
}