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
|
local dap, dapui, dap_install, dap_go = require("dap"), require("dapui"), require("dap-install"), require("dap-go")
require("nvim-dap-virtual-text").setup()
dapui.setup({
icons = { expanded = "▾", collapsed = "▸" },
layouts = {
{
elements = {
"scopes",
"breakpoints",
"stacks",
"watches",
},
size = 80,
position = "left",
},
{
elements = {
"repl",
-- 'console',
},
size = 10,
position = "bottom",
},
},
})
dap_go.setup()
vim.fn.sign_define("DapBreakpoint", { text = "ß", texthl = "", linehl = "", numhl = "" })
dap_install.config("php", {
configurations = {
{
type = "php",
request = "launch",
name = "Listen for Xdebug",
port = 9003,
pathMappings = function()
local sail = vim.call("composer#query", "require-dev.laravel/sail")
if sail == "" then
return { ["/app"] = vim.fn.getcwd() }
end
return { ["/var/www/html"] = vim.fn.getcwd() }
end,
},
},
})
-- Events Listeners
dap.listeners.after.event_initialized["dapui_config"] = function()
dapui.open({})
end
-- command to start debugging
-- run dap continue and enable the keybindings
-- when finish delete all keybindings
local bindings = {
{ mode = "n", lhs = "<leader>dd", rhs = dap.continue },
{ mode = "n", lhs = "<leader>dbp", rhs = dap.toggle_breakpoint },
{ mode = "n", lhs = "<leader>dl", rhs = dap.step_into },
{ mode = "n", lhs = "<leader>dj", rhs = dap.step_over },
{ mode = "n", lhs = "<leader>dk", rhs = dap.step_out },
{ mode = "n", lhs = "<leader>dc", rhs = dap.run_to_cursor },
{ mode = "v", lhs = "<leader>dv", rhs = dapui.eval },
}
vim.keymap.set("n", "<leader>dst", function()
dap.continue()
for _, bind in pairs(bindings) do
vim.keymap.set(bind.mode, bind.lhs, bind.rhs, { noremap = true })
end
end, { noremap = true })
vim.keymap.set("n", "<leader>dsp", function()
dap.terminate()
dapui.close({})
dap.clear_breakpoints()
for _, bind in pairs(bindings) do
vim.keymap.del("n", bind.lhs)
end
end, { noremap = true })
-- can be skipped since I can do it running the continue and promt to use the "Debug test"
vim.keymap.set("n", "<leader>dtt", dap_go.debug_test, { noremap = true })
|