79 lines
2.4 KiB
Lua
Executable File
79 lines
2.4 KiB
Lua
Executable File
local dap, dapui = require("dap"), require("dapui")
|
|
require("dapui").setup()
|
|
-- -- Set keymaps to control the debugger
|
|
vim.keymap.set("n", "<F5>", dap.continue)
|
|
vim.keymap.set("n", "<F10>", dap.step_over)
|
|
vim.keymap.set("n", "<F11>", dap.step_into)
|
|
vim.keymap.set("n", "<F12>", dap.step_out)
|
|
vim.keymap.set("n", "<leader>b", dap.toggle_breakpoint)
|
|
vim.keymap.set("n", "<leader>B", function()
|
|
dap.set_breakpoint(vim.fn.input("Breakpoint condition: "))
|
|
end)
|
|
|
|
require("dap-vscode-js").setup({
|
|
-- node_path = "node", -- Path of node executable. Defaults to $NODE_PATH, and then "node"
|
|
debugger_path = vim.fn.stdpath("data") .. "/lazy/vscode-js-debug", -- Path to vscode-js-debug installation.
|
|
-- debugger_cmd = { "extension" }, -- Command to use to launch the debug server. Takes precedence over `node_path` and `debugger_path`.
|
|
adapters = {
|
|
"chrome",
|
|
"pwa-node",
|
|
"pwa-chrome",
|
|
"pwa-msedge",
|
|
"node-terminal",
|
|
"pwa-extensionHost",
|
|
"node",
|
|
"chrome",
|
|
}, -- 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_based_languages = { "typescript", "javascript", "typescriptreact" }
|
|
|
|
for _, language in ipairs(js_based_languages) do
|
|
require("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-chrome",
|
|
request = "launch",
|
|
name = 'Start Chrome with "localhost"',
|
|
url = "http://localhost:3000",
|
|
webRoot = "${workspaceFolder}",
|
|
userDataDir = "${workspaceFolder}/.vscode/vscode-chrome-debug-userdatadir",
|
|
},
|
|
}
|
|
end
|
|
|
|
dap.listeners.before.attach.dapui_config = function()
|
|
print("before attach")
|
|
dapui.open()
|
|
end
|
|
dap.listeners.before.launch.dapui_config = function()
|
|
print("before launch")
|
|
dapui.open()
|
|
end
|
|
dap.listeners.before.event_terminated.dapui_config = function()
|
|
print("before terminated")
|
|
dapui.close()
|
|
end
|
|
dap.listeners.before.event_exited.dapui_config = function()
|
|
print("before exited")
|
|
dapui.close()
|
|
end
|
|
|
|
vim.keymap.set("n", "<leader>ui", require("dapui").toggle)
|