-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
135 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
return { | ||
"rcarriga/nvim-dap-ui", | ||
event = "LspAttach", | ||
dependencies = { | ||
"mfussenegger/nvim-dap", | ||
"nvim-neotest/nvim-nio", | ||
}, | ||
config = function() | ||
require("dapui").setup({}) | ||
local dap, dapui = require("dap"), require("dapui") | ||
dap.listeners.before.attach.dapui_config = function() | ||
dapui.open() | ||
end | ||
dap.listeners.before.launch.dapui_config = function() | ||
dapui.open() | ||
end | ||
dap.listeners.before.event_terminated.dapui_config = function() | ||
dapui.close() | ||
end | ||
dap.listeners.before.event_exited.dapui_config = function() | ||
dapui.close() | ||
end | ||
end, | ||
keys = { | ||
{ "<leader>ui", "<cmd>lua require'dapui'.toggle()<cr>", desc = "Toggle DAP UI" }, | ||
{ | ||
"<leader>uw", | ||
function() | ||
require("dapui").float_element("watches", { enter = true }) | ||
end, | ||
desc = "Toggle DAP UI", | ||
}, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
js = function(dap) | ||
dap.adapters["pwa-node"] = { | ||
type = "server", | ||
host = "localhost", | ||
port = "${port}", | ||
executable = { | ||
command = "js-debug-adapter", | ||
args = { "${port}" }, | ||
}, | ||
} | ||
for _, language in ipairs({ "typescript", "javascript" }) do | ||
require("dap").configurations[language] = { | ||
{ | ||
name = "Custom Debug Platform Model", | ||
type = "pwa-node", | ||
request = "attach", | ||
remoteRoot = "/usr/src/app", | ||
localRoot = "${workspaceFolder}", | ||
-- protocol = "inspector", | ||
port = 9229, | ||
restart = true, | ||
address = "0.0.0.0", | ||
skipFiles = { "<node_internals>/**" }, | ||
sourceMaps = true, | ||
}, | ||
{ | ||
type = "pwa-node", | ||
request = "attach", | ||
name = "Attach to node", | ||
processId = require("dap.utils").pick_process, | ||
cwd = "${workspaceFolder}", | ||
}, | ||
{ | ||
type = "pwa-node", | ||
request = "launch", | ||
name = "Launch file", | ||
program = "${file}", | ||
cwd = "${workspaceFolder}", | ||
}, | ||
---@diagnostic disable-next-line: missing-fields | ||
{ | ||
name = "-- launch.json --", | ||
}, | ||
} | ||
end | ||
end | ||
|
||
return { | ||
"mfussenegger/nvim-dap", | ||
event = "LspAttach", | ||
dependencies = { | ||
{ | ||
"theHamsta/nvim-dap-virtual-text", | ||
opts = {}, | ||
}, | ||
}, | ||
config = function() | ||
local dap = require("dap") | ||
-- setup dap config by VsCode launch.json file | ||
local vscode = require("dap.ext.vscode") | ||
local json = require("plenary.json") | ||
vscode.json_decode = function(str) | ||
return vim.json.decode(json.json_strip_comments(str)) | ||
end | ||
|
||
-- Extends dap.configurations with entries read from .vscode/launch.json | ||
if vim.fn.filereadable(".vscode/launch.json") then | ||
vscode.load_launchjs() | ||
end | ||
require("mason-nvim-dap").setup({}) | ||
js(dap) | ||
end, | ||
keys = { | ||
{ | ||
"<leader>b", | ||
"<cmd>lua require'dap'.toggle_breakpoint()<cr>", | ||
desc = "Toggle breakpoint", | ||
}, | ||
{ | ||
"<leader>bc", | ||
conditional_breakpoint, | ||
desc = "Conditional breakpoint", | ||
}, | ||
{ | ||
"<leader>bs", | ||
"<cmd>lua require'dap'.continue()<cr>", | ||
desc = "Debug continue", | ||
}, | ||
{ | ||
"<leader>bi", | ||
"<cmd>lua require'dap'.step_into()<cr>", | ||
desc = "Debug step into", | ||
}, | ||
{ | ||
"<leader>bo", | ||
"<cmd>lua require'dap'.step_over()<cr>", | ||
desc = "Debug step over", | ||
}, | ||
}, | ||
} |