58 lines
2.0 KiB
Lua
58 lines
2.0 KiB
Lua
|
local dap = require("dap")
|
||
|
local DEBUGGER_PATH = vim.fn.stdpath('data') .. "/lazy/vscode-js-debug"
|
||
|
|
||
|
require("dap-vscode-js").setup({
|
||
|
-- node_path = "node", -- Path of node executable. Defaults to $NODE_PATH, and then "node"
|
||
|
debugger_path = DEBUGGER_PATH, -- Path to vscode-js-debug installation.
|
||
|
-- debugger_cmd = { "js-debug-adapter" }, -- Command to use to launch the debug server. Takes precedence over `node_path` and `debugger_path`.
|
||
|
adapters = { 'firefox', 'pwa-node', 'pwa-chrome', 'pwa-msedge', 'node-terminal', 'pwa-extensionHost' }, -- which adapters to register in nvim-dap
|
||
|
-- log_file_path = "(stdpath cache)/dap_vscode_js.log" -- Path for file logging
|
||
|
-- log_file_level = false -- Logging level for output to file. Set to false to disable file logging.
|
||
|
-- log_console_level = vim.log.levels.ERROR -- Logging level for output to console. Set to false to disable console output.
|
||
|
})
|
||
|
|
||
|
local js_langs = {
|
||
|
"javascript",
|
||
|
"typescript",
|
||
|
"javascriptreact",
|
||
|
"typescriptreact",
|
||
|
}
|
||
|
|
||
|
for _, lang in ipairs(js_langs) do
|
||
|
|
||
|
dap.configurations[lang] = {
|
||
|
{
|
||
|
name = 'Next.js: debug server-side',
|
||
|
type = "pwa-node",
|
||
|
request = "launch",
|
||
|
skipFiles = {"<node_internals>/**"},
|
||
|
cwd = "${workspaceFolder}",
|
||
|
runtimeExecutable = "npm",
|
||
|
runtimeArgs = {"run-script", "dev"},
|
||
|
},
|
||
|
{
|
||
|
name = 'Next.js: debug client-side',
|
||
|
type = 'pwa-chrome',
|
||
|
request = 'launch',
|
||
|
url = 'http://localhost:3000',
|
||
|
webRoot = '${workspaceFolder}',
|
||
|
sourceMaps = true, -- https://github.com/vercel/next.js/issues/56702#issuecomment-1913443304
|
||
|
sourceMapPathOverrides = {
|
||
|
['webpack://_N_E/*'] = '${webRoot}/*',
|
||
|
},
|
||
|
},
|
||
|
{
|
||
|
name = "Next.js: debug full stack",
|
||
|
type = "node-terminal",
|
||
|
request = "launch",
|
||
|
command = "npm run dev",
|
||
|
serverReadyAction = {
|
||
|
pattern = "- Local:.+(https?://.+)",
|
||
|
uriFormat = "%s",
|
||
|
action = "debugWithChrome"
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
end;
|