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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
|
local dap, dapui, dap_go = require("dap"), require("dapui"), require("dap-go")
require("nvim-dap-virtual-text").setup({})
-- dap.set_log_level('TRACE')
dap_go.setup()
dapui.setup({
icons = { expanded = "▾", collapsed = "▸" },
layouts = {
{
elements = {
"scopes",
"breakpoints",
"stacks",
"watches",
},
size = 80,
position = "left",
},
{
elements = {
"repl",
"console",
},
size = 10,
position = "bottom",
},
},
})
vim.fn.sign_define("DapBreakpoint", { text = "🛑", texthl = "", linehl = "", numhl = "" })
vim.fn.sign_define("DapStopped", { text = "▶", texthl = "", linehl = "", numhl = "" })
vim.fn.sign_define("DapBreakpointRejected", { text = "🚫", texthl = "", linehl = "", numhl = "" })
vim.fn.sign_define("DapBreakpointCondition", { text = "❓", texthl = "", linehl = "", numhl = "" })
vim.fn.sign_define("DapLogPoint", { text = "💬", texthl = "", linehl = "", numhl = "" })
dap.adapters.php = {
type = "executable",
command = "php-debug-adapter",
}
dap.configurations.php = {
{
type = "php",
request = "launch",
name = "Laravel",
port = 9003,
pathMappings = {
["/var/www/html"] = "${workspaceFolder}",
},
},
{
type = "php",
request = "launch",
name = "Symfony",
port = 9003,
pathMappings = {
["/app"] = "${workspaceFolder}",
},
},
}
require("dap-vscode-js").setup({
-- node_path = "node", -- Path of node executable. Defaults to $NODE_PATH, and then "node"
-- debugger_path = "(runtimedir)/site/pack/packer/opt/vscode-js-debug", -- Path to vscode-js-debug installation.
debugger_cmd = { "js-debug-adapter" }, -- Command to use to launch the debug server. Takes precedence over `node_path` and `debugger_path`.
adapters = { "pwa-node", "pwa-chrome", "pwa-msedge", "node-terminal", "pwa-extensionHost" }, -- 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.
})
for _, language in ipairs({ "typescript", "javascript" }) 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}",
},
}
end
for _, language in ipairs({ "typescriptreact", "javascriptreact" }) do
require("dap").configurations[language] = {
{
type = "pwa-chrome",
name = "Attach - Remote Debugging",
request = "attach",
program = "${file}",
cwd = vim.fn.getcwd(),
sourceMaps = true,
protocol = "inspector",
port = 9222,
webRoot = "${workspaceFolder}",
},
{
type = "pwa-chrome",
name = "Launch Chrome",
request = "launch",
url = "http://localhost:3000",
},
}
end
-- Events Listeners
dap.listeners.after.event_initialized["dapui_config"] = function()
dapui.open({})
end
local hydra = require("hydra")
local hint = [[
Nvim DAP
_d_: Start/Continue _j_: StepOver _k_: StepOut _l_: StepInto ^
_bp_: Toogle Breakpoint _bc_: Conditional Breakpoint ^
_?_: log point ^
_c_: Run To Cursor ^
_h_: Show information of the variable under the cursor ^
_x_: Stop Debbuging ^
^^ _<Esc>_
]]
hydra({
name = "dap",
hint = hint,
mode = "n",
config = {
color = "blue",
invoke_on_body = true,
hint = {
border = "rounded",
position = "bottom",
},
},
body = "<leader>d",
heads = {
{ "d", dap.continue },
{ "bp", dap.toggle_breakpoint },
{ "l", dap.step_into },
{ "j", dap.step_over },
{ "k", dap.step_out },
{ "h", dapui.eval },
{ "c", dap.run_to_cursor },
{
"bc",
function()
vim.ui.input({ prompt = "Condition: " }, function(condition)
dap.set_breakpoint(condition)
end)
end,
},
{
"?",
function()
vim.ui.input({ prompt = "Log: " }, function(log)
dap.set_breakpoint(nil, nil, log)
end)
end,
},
{
"x",
function()
dap.terminate()
dapui.close({})
dap.clear_breakpoints()
end,
},
{ "<Esc>", nil, { exit = true } },
},
})
|