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,27 +203,29 @@ return {
},
opts = function()
local dap = require("dap")
if not dap.adapters["pwa-node"] then
require("dap").adapters["pwa-node"] = {
for _, adapterType in ipairs({ "node", "chrome", "msedge" }) do
local pwaType = "pwa-" .. adapterType
if not dap.adapters[pwaType] then
dap.adapters[pwaType] = {
type = "server",
host = "localhost",
port = "${port}",
executable = {
command = "node",
-- 💀 Make sure to update this path to point to your installation
args = {
LazyVim.get_pkg_path("js-debug-adapter", "/js-debug/src/dapDebugServer.js"),
"${port}",
},
command = "js-debug-adapter",
args = { "${port}" },
},
}
end
if not dap.adapters["node"] then
dap.adapters["node"] = function(cb, config)
if config.type == "node" then
config.type = "pwa-node"
end
local nativeAdapter = dap.adapters["pwa-node"]
-- Define adapters without the "pwa-" prefix for VSCode compatibility
if not dap.adapters[adapterType] then
dap.adapters[adapterType] = function(cb, config)
local nativeAdapter = dap.adapters[pwaType]
config.type = pwaType
if type(nativeAdapter) == "function" then
nativeAdapter(cb, config)
else
@ -231,6 +233,7 @@ return {
end
end
end
end
local js_filetypes = { "typescript", "javascript", "typescriptreact", "javascriptreact" }