dotfiles/nvim/lua/dap_config.lua

80 lines
2.1 KiB
Lua

vim.fn.sign_define('DapBreakpoint', {text='🟥', texthl='', linehl='', numhl=''})
vim.fn.sign_define('DapStopped', {text='⭐️', texthl='', linehl='', numhl=''})
local dap = require('dap')
local M ={}
local DEBUGGER_PATH = {os.getenv('HOME')..'/.local/share/nvim/mason/packages/js-debug-adapter'}
function M.setup()
require('dap-vscode-js').setup {
node_path = "node",
debugger_path = DEBUGGER_PATH,
adapters = {"pwa-node","pwa-chrome","pwa-msedge","node-terminal", "pwa-extensionHost"}
}
for _, language in ipairs {"typescript", "javascript"} do
dap.configurations[language] = {
type = "pwa-node",
request = "launch",
name = "Launch File",
program = "${file}",
cwd = "${workspacefolder}"
},
{
type = "pwa-node",
request = "attach",
name = "Attach",
processId = require("dap.utils").pick_process,
cwd = "${workspacefolder}"
},
{
type = "pwa-node",
request = "launch",
name = "Debug Jest Tests",
runtimeExecutable = "node",
runtimeArgs = {
"./node_modules/jest/bin/jestj",
"--runInBand",
},
rootPath = "${workspaceFolder}",
console = "integratedTerminal",
internalConsoleOptions = "neverOpen",
cwd = "${workspacefolder}"
}
end
end
local function configure_debuggers()
require("config.dap.javascript").setup()
require("config.dap.typescript").setup()
end
return M
--dap.adapters.node2 = {
-- type = 'executable',
-- command = 'node',
-- args = {os.getenv('HOME') .. '/.local/share/nvim/mason/packages/node-debug2-adapter/out/src/nodeDebug.js'},
--}
--dap.configurations.javascript = {
-- {
-- name = 'Launch',
-- type = 'node2',
-- request = 'launch',
-- program = '${file}',
-- cwd = vim.fn.getcwd(),
-- sourceMaps = true,
-- protocol = 'inspector',
-- console = 'integratedTerminal',
-- },
-- {
-- -- For this to work you need to make sure the node process is started with the `--inspect` flag.
-- name = 'Attach to process',
-- type = 'node2',
-- request = 'attach',
-- processId = require'dap.utils'.pick_process,
-- },
--}