nvim: get basic cpp debugging working

This commit is contained in:
dogeystamp 2024-03-29 17:58:54 -04:00
parent 3c3bb83ff7
commit c3669df95a
Signed by: dogeystamp
GPG Key ID: 7225FE3592EFFA38
3 changed files with 36 additions and 5 deletions

View File

@ -131,10 +131,12 @@ python-black
bash-language-server
vscode-css-languageserver
rust-analyzer
gdb
lldb
python-debugpy
arc-gtk-theme
lxappearance-gtk3
radare2
gdb
typst
# .local/bin/pyinstantref script

5
src/.clang-format Normal file
View File

@ -0,0 +1,5 @@
---
BasedOnStyle: LLVM
UseTab: Always
IndentWidth: 4
TabWidth: 4

View File

@ -16,9 +16,12 @@ local dapui = require("dapui")
-- key bindings
----------------
keymap("<leader>dd", dapui.setup)
keymap("<leader>rs", dap.continue)
keymap("<leader>rt", dap.restart)
keymap("<leader>rt", function()
-- hard restart (lldb just stops when restarted)
dap.terminate()
dap.continue()
end)
keymap("<leader>rr", dap.terminate)
keymap("<c-p>", dap.step_into)
keymap("<c-n>", dap.step_over)
@ -90,10 +93,10 @@ end
dap.listeners.after.attach.dapui_config = function()
dapui.open()
end
dap.listeners.after.event_terminated.dapui_config = function()
dap.listeners.before.event_terminated.dapui_config = function()
dapui.close()
end
dap.listeners.after.event_exited.dapui_config = function()
dap.listeners.before.event_exited.dapui_config = function()
dapui.close()
end
@ -140,3 +143,24 @@ dap.configurations.python = {
console = "integratedTerminal";
}
}
-- https://github.com/mfussenegger/nvim-dap/wiki/Debug-Adapter-installation#ccrust-via-gdb
dap.adapters.lldb = {
type = "executable",
command = "/usr/bin/lldb-vscode",
name = "lldb"
}
dap.configurations.cpp = {
{
name = "launch binary",
type = "lldb",
request = "launch",
program = function()
return vim.fn.input("binary: ", vim.fn.getcwd() .. "/", "file")
end,
cwd = "${workspaceFolder}",
stopOnEntry = false,
runInTerminal = true,
}
}