diff --git a/nvim/dot-config/nvim/lazy-lock.json b/nvim/dot-config/nvim/lazy-lock.json index 3c598f2..893a736 100644 --- a/nvim/dot-config/nvim/lazy-lock.json +++ b/nvim/dot-config/nvim/lazy-lock.json @@ -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" }, diff --git a/nvim/dot-config/nvim/lua/plugins/dap.lua b/nvim/dot-config/nvim/lua/plugins/dap.lua new file mode 100644 index 0000000..eb395e4 --- /dev/null +++ b/nvim/dot-config/nvim/lua/plugins/dap.lua @@ -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", "", function() + require("dap").continue() + end, { desc = "Continue" }) + vim.keymap.set("n", "", function() + require("dap").step_over() + end, { desc = "Step over" }) + vim.keymap.set("n", "", function() + require("dap").step_into() + end, { desc = "Step into" }) + vim.keymap.set("n", "", function() + require("dap").step_out() + end, { desc = "Step out" }) + vim.keymap.set("n", "bp", function() + require("dap").toggle_breakpoint() + end, { desc = "[B]reak[P]oint" }) + -- vim.keymap.set("n", "lp", function() + -- require("dap").set_breakpoint(nil, nil, vim.fn.input("Log point message: ")) + -- end) + vim.keymap.set("n", "dr", function() + require("dap").repl.open() + end, { desc = "[D]ebug [R]epl" }) + -- vim.keymap.set("n", "dl", function() + -- require("dap").run_last() + -- end) + vim.keymap.set({ "n", "v" }, "dh", function() + require("dap.ui.widgets").hover() + end, { desc = "[D]ebug [H]over" }) + vim.keymap.set("n", "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", "close!", { noremap = true, silent = true }) + end, + }) + end, + }, + { + "theHamsta/nvim-dap-virtual-text", + dependencies = { + "mfussenegger/nvim-dap", + }, + opts = { + virt_text_pos = "eol", + only_first_definition = false, + }, + }, +} diff --git a/nvim/dot-config/nvim/lua/tools.lua b/nvim/dot-config/nvim/lua/tools.lua index 7726bec..7dab5e4 100644 --- a/nvim/dot-config/nvim/lua/tools.lua +++ b/nvim/dot-config/nvim/lua/tools.lua @@ -75,6 +75,8 @@ tools.formatters = require("util.conform").assign_formatters({ }) -- https://mason-registry.dev/registry/list -tools.extra = {} +tools.extra = { + "cpptools", +} return tools