142 lines
4.0 KiB
Lua
142 lines
4.0 KiB
Lua
return {
|
|
"rcarriga/nvim-dap-ui",
|
|
dependencies = { "mfussenegger/nvim-dap", "nvim-neotest/nvim-nio" },
|
|
config = function()
|
|
local dap, dapui = require("dap"), require("dapui")
|
|
local color_blend = require("color_blend")
|
|
|
|
dap.defaults.fallback.external_terminal = {
|
|
command = "/usr/bin/kitty",
|
|
args = { "-e" },
|
|
}
|
|
|
|
dap.defaults.fallback.force_external_terminal = true
|
|
|
|
dap.adapters.gdb = {
|
|
type = "executable",
|
|
command = "gdb",
|
|
args = {
|
|
"--interpreter=dap",
|
|
"--eval-command",
|
|
"set print pretty on",
|
|
},
|
|
}
|
|
|
|
-- Define the custom highlight group for the stopped line
|
|
vim.api.nvim_set_hl(0, "DapCustomHighlight", { bg = "#44475a", fg = "NONE" })
|
|
|
|
-- Define the custom highlight group for Breakpoint
|
|
vim.api.nvim_set_hl(0, "DapCustomBreakpoint", { bg = "NONE", fg = "#ff5555" })
|
|
|
|
-- Define the custom highlight group for Breakpoint line
|
|
vim.api.nvim_set_hl(
|
|
0,
|
|
"DapCustomBreakpointLine",
|
|
{ bg = color_blend.blend_colors("#a1112a", "#000000", 0.5), fg = "NONE" }
|
|
)
|
|
|
|
vim.fn.sign_define("DapBreakpoint", {
|
|
text = " ", -- nerdfonts icon here
|
|
texthl = "DapCustomBreakpoint",
|
|
linehl = "DapCustomBreakpointLine",
|
|
numhl = "DapBreakpoint",
|
|
})
|
|
vim.fn.sign_define("DapStopped", {
|
|
text = "->", -- nerdfonts icon here TODO:: add a different icon depending on my nerd font
|
|
texthl = "",
|
|
linehl = "DapCustomHighlight",
|
|
numhl = "DapBreakpoint",
|
|
})
|
|
|
|
dap.configurations.c = {
|
|
{
|
|
name = "Launch",
|
|
type = "gdb",
|
|
request = "launch",
|
|
program = function()
|
|
return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file")
|
|
end,
|
|
cwd = "${workspaceFolder}",
|
|
stopAtBeginningOfMainSubprogram = false,
|
|
console = "externalTerminal",
|
|
},
|
|
{
|
|
name = "Select and attach to process",
|
|
type = "gdb",
|
|
request = "attach",
|
|
program = function()
|
|
return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file")
|
|
end,
|
|
pid = function()
|
|
local name = vim.fn.input("Executable name (filter): ")
|
|
return require("dap.utils").pick_process({ filter = name })
|
|
end,
|
|
cwd = "${workspaceFolder}",
|
|
},
|
|
{
|
|
name = "Attach to gdbserver :1234",
|
|
type = "gdb",
|
|
request = "attach",
|
|
target = "localhost:1234",
|
|
program = function()
|
|
return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file")
|
|
end,
|
|
cwd = "${workspaceFolder}",
|
|
},
|
|
}
|
|
|
|
dap.configurations.cpp = dap.configurations.c
|
|
|
|
vim.keymap.set("n", "<Leader>b", function()
|
|
require("dap").toggle_breakpoint()
|
|
end, { desc = "DAP-UI: toggle [B]reakpoint" })
|
|
|
|
vim.keymap.set("n", "<Leader>ev", function()
|
|
require("dapui").eval(nil, { enter = true })
|
|
end, { desc = "DAP-UI: [E][v]aluate line" })
|
|
|
|
-- vim.keymap.set("n", "<Leader>df", function()
|
|
-- local widgets = require("dap.ui.widgets")
|
|
-- widgets.centered_float(widgets.frames)
|
|
-- end)
|
|
|
|
-- vim.keymap.set("n", "<Leader>dr", function()
|
|
-- require("dap").repl.open()
|
|
-- -- Set up autocmd for terminal mode to handle color properly
|
|
-- vim.cmd([[
|
|
-- autocmd TermOpen * setlocal nonumber norelativenumber | startinsert
|
|
-- ]])
|
|
-- end)
|
|
|
|
vim.keymap.set("n", "<F5>", function()
|
|
require("dap").continue()
|
|
end, { desc = "DAP-UI: [F5] continue" })
|
|
vim.keymap.set("n", "<F10>", function()
|
|
require("dap").step_over()
|
|
end, { desc = "DAP-UI: [F10] step over" })
|
|
vim.keymap.set("n", "<F11>", function()
|
|
require("dap").step_into()
|
|
end, { desc = "DAP-UI: [F11] step into" })
|
|
vim.keymap.set("n", "<F12>", function()
|
|
require("dap").step_out()
|
|
end, { desc = "DAP-UI: [F12] step out" })
|
|
|
|
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
|
|
|
|
vim.keymap.set("n", "<Leader>df", function()
|
|
require("dapui").toggle()
|
|
end, { desc = "DAP-UI: Toggle Debug Window" })
|
|
end,
|
|
}
|