Added nvim-dap

This commit is contained in:
Tim Huizinga 2024-07-24 16:50:38 +02:00
parent b3e20c39c7
commit a4a5afe3a9
3 changed files with 103 additions and 1 deletions

View File

@ -30,6 +30,8 @@
"nvim-cmp": { "branch": "main", "commit": "a110e12d0b58eefcf5b771f533fc2cf3050680ac" },
"nvim-cmp-lsp-rs": { "branch": "main", "commit": "d9ebeca9ea07ba2fd57f997b2d6a8bc7da51abed" },
"nvim-colorizer.lua": { "branch": "master", "commit": "85855b38011114929f4058efc97af1059ab3e41d" },
"nvim-dap": { "branch": "master", "commit": "bc03b83c94d0375145ff5ac6a6dcf28c1241e06f" },
"nvim-dap-virtual-text": { "branch": "master", "commit": "484995d573c0f0563f6a66ebdd6c67b649489615" },
"nvim-lspconfig": { "branch": "master", "commit": "1d2454f9fbb34206897b9a1b5e8b87d6418941ba" },
"nvim-surround": { "branch": "main", "commit": "ec2dc7671067e0086cdf29c2f5df2dd909d5f71f" },
"nvim-treesitter": { "branch": "master", "commit": "984604288d56265d7cfc443fa9dc9f67ec19d60d" },

View File

@ -0,0 +1,98 @@
-- https://github.com/mfussenegger/nvim-dap
return {
{
"mfussenegger/nvim-dap",
config = function()
local dap = require("dap")
dap.adapters.cppdbg = {
id = "cppdbg",
type = "executable",
command = "OpenDebugAD7",
}
dap.configurations.cpp = {
{
name = "Launch file",
type = "cppdbg",
request = "launch",
program = function()
return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file")
end,
cwd = "${workspaceFolder}",
-- stopAtEntry = true,
},
-- {
-- name = "Attach to gdbserver :1234",
-- type = "cppdbg",
-- request = "launch",
-- MIMode = "gdb",
-- miDebuggerServerAddress = "localhost:1234",
-- miDebuggerPath = "/usr/bin/gdb",
-- cwd = "${workspaceFolder}",
--
-- program = function()
-- return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file")
-- end,
-- },
}
dap.configurations.c = dap.configurations.cpp
dap.configurations.rust = dap.configurations.cpp
dap.defaults.fallback.force_external_terminal = true
dap.defaults.fallback.external_terminal = {
command = "tmux",
args = { "new-window" },
}
vim.keymap.set("n", "<F5>", function()
require("dap").continue()
end, { desc = "Continue" })
vim.keymap.set("n", "<F10>", function()
require("dap").step_over()
end, { desc = "Step over" })
vim.keymap.set("n", "<F11>", function()
require("dap").step_into()
end, { desc = "Step into" })
vim.keymap.set("n", "<F12>", function()
require("dap").step_out()
end, { desc = "Step out" })
vim.keymap.set("n", "<Leader>bp", function()
require("dap").toggle_breakpoint()
end, { desc = "[B]reak[P]oint" })
-- vim.keymap.set("n", "<Leader>lp", function()
-- require("dap").set_breakpoint(nil, nil, vim.fn.input("Log point message: "))
-- end)
vim.keymap.set("n", "<Leader>dr", function()
require("dap").repl.open()
end, { desc = "[D]ebug [R]epl" })
-- vim.keymap.set("n", "<Leader>dl", function()
-- require("dap").run_last()
-- end)
vim.keymap.set({ "n", "v" }, "<Leader>dh", function()
require("dap.ui.widgets").hover()
end, { desc = "[D]ebug [H]over" })
vim.keymap.set("n", "<Leader>df", function()
local widgets = require("dap.ui.widgets")
widgets.centered_float(widgets.frames)
end, { desc = "[D]ebug [F]rames" })
vim.api.nvim_create_autocmd("FileType", {
pattern = "dap-float",
callback = function()
vim.api.nvim_buf_set_keymap(0, "n", "q", "<cmd>close!<CR>", { noremap = true, silent = true })
end,
})
end,
},
{
"theHamsta/nvim-dap-virtual-text",
dependencies = {
"mfussenegger/nvim-dap",
},
opts = {
virt_text_pos = "eol",
only_first_definition = false,
},
},
}

View File

@ -75,6 +75,8 @@ tools.formatters = require("util.conform").assign_formatters({
})
-- https://mason-registry.dev/registry/list
tools.extra = {}
tools.extra = {
"cpptools",
}
return tools