Skip to content

Commit

Permalink
feat(dap): added run with args leader-ca. Fixes #1629
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Oct 10, 2023
1 parent 4719dad commit b1c9fd1
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lua/lazyvim/plugins/extras/dap/core.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
---@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 {}
---@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",

Expand Down Expand Up @@ -76,6 +87,7 @@ return {
{ "<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" },
{ "<leader>dg", function() require("dap").goto_() end, desc = "Go to line (no execute)" },
{ "<leader>di", function() require("dap").step_into() end, desc = "Step Into" },
Expand Down

0 comments on commit b1c9fd1

Please sign in to comment.