fix(typescript): support more dap adapters

Make sure that pwa-node, pwa-chrome, pwa-msedge, node, chrome and msedge
are supported out of the box
This commit is contained in:
Alexey Svirshchevskiy 2025-08-09 14:23:18 +02:00
parent c5b49b52cf
commit 12d8fa9702

View file

@ -203,31 +203,34 @@ return {
}, },
opts = function() opts = function()
local dap = require("dap") local dap = require("dap")
if not dap.adapters["pwa-node"] then
require("dap").adapters["pwa-node"] = { for _, adapterType in ipairs({ "node", "chrome", "msedge" }) do
type = "server", local pwaType = "pwa-" .. adapterType
host = "localhost",
port = "${port}", if not dap.adapters[pwaType] then
executable = { dap.adapters[pwaType] = {
command = "node", type = "server",
-- 💀 Make sure to update this path to point to your installation host = "localhost",
args = { port = "${port}",
LazyVim.get_pkg_path("js-debug-adapter", "/js-debug/src/dapDebugServer.js"), executable = {
"${port}", command = "js-debug-adapter",
args = { "${port}" },
}, },
}, }
} end
end
if not dap.adapters["node"] then -- Define adapters without the "pwa-" prefix for VSCode compatibility
dap.adapters["node"] = function(cb, config) if not dap.adapters[adapterType] then
if config.type == "node" then dap.adapters[adapterType] = function(cb, config)
config.type = "pwa-node" local nativeAdapter = dap.adapters[pwaType]
end
local nativeAdapter = dap.adapters["pwa-node"] config.type = pwaType
if type(nativeAdapter) == "function" then
nativeAdapter(cb, config) if type(nativeAdapter) == "function" then
else nativeAdapter(cb, config)
cb(nativeAdapter) else
cb(nativeAdapter)
end
end end
end end
end end