diff --git a/lua/tiny-debugger/adapters/javascript.lua b/lua/tiny-debugger/adapters/javascript.lua index a564707..bf1f864 100644 --- a/lua/tiny-debugger/adapters/javascript.lua +++ b/lua/tiny-debugger/adapters/javascript.lua @@ -1 +1,43 @@ -return {} +local loader = require("tiny-debugger.adapters.init") + +local M = {} + +function M.register(dap) + local js_debug = loader.find_executable({ "js-debug-adapter" }) + if not js_debug then return end + + local adapter = { + type = "server", + host = "localhost", + port = "${port}", + executable = { + command = js_debug, + args = { "${port}" }, + }, + } + + local configurations = { + { + type = "pwa-node", + request = "launch", + name = "Launch file", + program = "${file}", + cwd = "${workspaceFolder}", + }, + { + type = "pwa-node", + request = "attach", + name = "Attach", + processId = function() + return require("dap.utils").pick_process() + end, + cwd = "${workspaceFolder}", + }, + } + + loader.register(dap, "pwa-node", adapter, configurations, { + "javascript", "typescript", "javascriptreact", "typescriptreact", + }) +end + +return M