Skip to content

Instantly share code, notes, and snippets.

@AlanWarren
Created November 30, 2023 14:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlanWarren/ac82901d9680eb5f5f7ddceecc307207 to your computer and use it in GitHub Desktop.
Save AlanWarren/ac82901d9680eb5f5f7ddceecc307207 to your computer and use it in GitHub Desktop.
-- NOTE: go to vscode-js-debug and npm install --legacy-peer-deps
-- && npx gulp vsDebugServerBundle && mv dist out
require("dap-vscode-js").setup({
debugger_path = "/Users/example/dev/build/vscode-js-debug", -- Path to vscode-js-debug installation.
adapters = { 'pwa-node', 'pwa-chrome', 'pwa-msedge', 'node-terminal', 'pwa-extensionHost' }, -- which adapters to register in nvim-dap
})
for _, language in ipairs({ "typescript", "typescriptreact", "javascript", "javascriptreact" }) do
require("dap").configurations[language] = {
{
name = 'Node - Launch',
type = 'pwa-node',
request = 'launch',
program = '${file}',
rootPath = '${workspaceFolder}',
cwd = '${workspaceFolder}',
sourceMaps = true,
skipFiles = { '<node_internals>/**' },
protocol = 'inspector',
console = 'integratedTerminal',
},
{
type = "pwa-node",
request = "attach",
name = "Node - Attach",
cwd = "${workspaceFolder}",
port = 9222,
processId = require 'dap.utils'.pick_process,
skipFiles = { "<node_internals>/**" },
},
{
type = "pwa-chrome",
request = "attach",
name = "Attach to Chrome",
program = "${file}",
cwd = vim.fn.getcwd(),
urlFilter = "localhost:5173/*",
-- sourceMaps = true,
-- enableContentValidation = false,
skipFiles = {
"<node_internals>/**",
"chrome-extension://**",
"${workspaceFolder}/node_modules/**/*.js",
},
port = 9222,
webRoot = "${workspaceFolder}",
},
{
type = "pwa-chrome",
name = "Launch chrome",
request = "launch",
webRoot = "${workspaceFolder}",
url = "http://localhost:3080",
},
{
type = "pwa-msedge",
name = "Launch Edge",
request = "launch",
userDataDir = "${env:HOME}/dev/temp/edge",
webRoot = "${workspaceFolder}",
url = "http://localhost:3000",
-- urlFilter = "localhost:3000/*",
},
{
type = 'pwa-node',
request = 'launch',
name = 'Launch Test Program (vitest)',
cwd = vim.fn.getcwd(),
program = '${workspaceFolder}/node_modules/vitest/vitest.mjs',
args = { '--inspect-brk', '--threads', 'false', 'run', '${file}' },
autoAttachChildProcesses = true,
smartStep = true,
console = 'integratedTerminal',
skipFiles = { '<node_internals>/**', 'node_modules/**' },
},
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment