-
Notifications
You must be signed in to change notification settings - Fork 3
/
nvim-dap.lua
91 lines (85 loc) · 2.91 KB
/
nvim-dap.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
local dap, dapui = require("dap"), require("dapui");
require("nvim-dap-virtual-text").setup({
commented = true
});
dapui.setup();
-- Adapters
require("dap-vscode-js").setup({
adapters = { 'pwa-node', 'pwa-chrome' },
})
for _, language in ipairs({ 'javascript', 'typescript', 'typescriptreact' }) do
dap.configurations[language] = {
{
type = "pwa-node",
request = "launch",
name = "Debug JavaScript/Typescript File (Node)",
skipFiles = {
"<node_internals>/**",
"node_modules/**",
"**/node_modules/**",
},
runtimeExecutable = "ts-node",
program = "${file}",
cwd = "${workspaceFolder}",
sourceMaps = true,
},
{
type = "pwa-node",
request = "launch",
name = "Debug Jest Tests - \"Ensure you have jest as your dependencies\" (Node)",
-- trace = true, -- include debugger info
runtimeExecutable = "node",
runtimeArgs = {
"./node_modules/jest/bin/jest.js",
"--runInBand",
},
rootPath = "${workspaceFolder}",
cwd = "${workspaceFolder}",
console = "integratedTerminal",
internalConsoleOptions = "neverOpen",
},
{
type = "pwa-chrome",
request = "launch",
name = "Debug React Apps -> Vite, NextJs (Chrome)",
url = "http://localhost:5173", -- Change the URL to match your Node.js web app
webRoot = "${workspaceFolder}",
sourceMapPathOverrides = {
["webpack:///*"] = "${webRoot}/*",
["webpack:///./~/*"] = "${webRoot}/node_modules/*",
},
skipFiles = {
"<node_internals>/**",
"node_modules/**",
"**/react/**",
"**/react-dom/**",
"**/react-scripts/**", -- If you're using create-react-app
"**/webpack/**", -- Skip webpack internals
"**/babel/**", -- Skip babel internals
"**/jest/**", -- Skip jest internals
"**/vite/**", -- Skip vite internals
"**/.vite/**", -- Skip vite internals
"**/dist/**", -- Skip dist directories
"**/next/**", -- Skip Next.js internals
"**/.next/**", -- Skip Next.js build output
},
sourceMaps = true,
},
}
end
dap.listeners.before.attach.dapui_config = function()
dapui.open("stack");
end
dap.listeners.before.launch.dapui_config = function()
dapui.open("stack");
end
dap.listeners.before.event_terminated.dapui_config = function()
dapui.close()
end
dap.listeners.before.event_exited.dapui_config = function()
dapui.close()
end
vim.keymap.set('n', '<Leader>db', function() dap.toggle_breakpoint() end, { noremap = true, silent = true });
vim.keymap.set('n', '<Leader>dc', function() dap.continue() end, { noremap = true, silent = true });
vim.keymap.set('n', '<Leader>di', function() dap.step_into() end, { noremap = true, silent = true });
vim.keymap.set('n', '<Leader>do', function() dap.step_over() end, { noremap = true, silent = true });