--[ --This plugin add support for Debug Adapter Protocol to connect to various debugger -- -- C\C++ => gdb => via ... -- GoLang => delve => via nvim-dap-go -- Python => XXXXX => via XXXX --] return { "https://codeberg.org/mfussenegger/nvim-dap.git", dependencies = { "rcarriga/nvim-dap-ui", "leoluz/nvim-dap-go", }, config = function() local dap = require("dap") local dapui = require("dapui") dapui.setup() require("dap-go").setup() 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 if vim.fn.executable("codelldb") == 1 then dap.adapters.codelldb = { type = "server", port = "${port}", executable = { command = "codelldb", -- or if not in $PATH: "/absolute/path/to/codelldb" args = { "--port", "${port}" }, -- On windows you may have to uncomment this: -- detached = false, }, } end if vim.fn.executable("gdb") == 1 then dap.adapters.gdb = { id = "gdb", type = "executable", command = "gdb", args = { "--quiet", "--interpreter=dap" }, } end dap.configurations.cpp = { { name = "Launch file", type = "codelldb", request = "launch", program = function() return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file") end, cwd = "${workspaceFolder}", stopOnEntry = false, }, } dap.configurations.c = dap.configurations.cpp -- dap.configurations.rust = dap.configurations.cpp -- dap.configurations.c = { -- { -- name = "Run executable (GDB)", -- type = "gdb", -- request = "launch", -- -- This requires special handling of 'run_last', see -- -- https://github.com/mfussenegger/nvim-dap/issues/1025#issuecomment-1695852355 -- program = function() -- local path = vim.fn.input({ -- prompt = "Path to executable: ", -- default = vim.fn.getcwd() .. "/", -- completion = "file", -- }) -- -- return (path and path ~= "") and path or dap.ABORT -- end, -- }, -- { -- name = "Run executable with arguments (GDB)", -- type = "gdb", -- request = "launch", -- -- This requires special handling of 'run_last', see -- -- https://github.com/mfussenegger/nvim-dap/issues/1025#issuecomment-1695852355 -- program = function() -- local path = vim.fn.input({ -- prompt = "Path to executable: ", -- default = vim.fn.getcwd() .. "/", -- completion = "file", -- }) -- -- return (path and path ~= "") and path or dap.ABORT -- end, -- args = function() -- local args_str = vim.fn.input({ -- prompt = "Arguments: ", -- }) -- return vim.split(args_str, " +") -- end, -- }, -- { -- name = "Attach to process (GDB)", -- type = "gdb", -- request = "attach", -- processId = require("dap.utils").pick_process, -- }, -- } -- Adds keymaps vim.keymap.set("n", "Dt", dap.toggle_breakpoint, { desc = "Debugger toggle breakpoint" }) vim.keymap.set("n", "Dc", dap.continue, { desc = "Debugger continue" }) end, } -- return { -- "https://codeberg.org/mfussenegger/nvim-dap.git", -- enabled = true, -- config = function() -- if vim.fn.executable("gdb") == 1 then -- local dap = require("dap").setup() -- dap.adapters.gdb = { -- id = "gdb", -- type = "executable", -- command = "gdb", -- args = { "--quiet", "--interpreter=dap" }, -- } -- end -- end, -- } --