+---@param config {args?:string[]|fun():string[]?}
+local function get_args(config)
+ local args = type(config.args) == "function" and (config.args() or {}) or config.args or {}
+ config = vim.deepcopy(config)
+ ---@cast args string[]
+ config.args = function()
+ local new_args = vim.fn.input("Run with args: ", table.concat(args, " ")) --[[@as string]]
+ return vim.split(vim.fn.expand(new_args) --[[@as string]], " ")
+ end
+ return config
+end
+
return {
"mfussenegger/nvim-dap",
{ "<leader>dB", function() require("dap").set_breakpoint(vim.fn.input('Breakpoint condition: ')) end, desc = "Breakpoint Condition" },
{ "<leader>db", function() require("dap").toggle_breakpoint() end, desc = "Toggle Breakpoint" },
{ "<leader>dc", function() require("dap").continue() end, desc = "Continue" },
+ { "<leader>da", function() require("dap").continue({ before = get_args }) end, desc = "Run with Args" },
{ "<leader>dC", function() require("dap").run_to_cursor() end, desc = "Run to Cursor" },
{ "<C-T>", function() require("dap").run_to_cursor() end, desc = "Run to Cursor" },
{ "<leader>dg", function() require("dap").goto_() end, desc = "Go to line (no execute)" },