From 25110f511b053a08ce2d873cfc0a39e40b1ec21f Mon Sep 17 00:00:00 2001 From: thoxy Date: Mon, 16 Oct 2023 20:25:25 +0200 Subject: [PATCH] add dap debug with codelldb --- lua/lazyvim/plugins/extras/lang/zig.lua | 34 +++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/lua/lazyvim/plugins/extras/lang/zig.lua b/lua/lazyvim/plugins/extras/lang/zig.lua index 45999bd6..7fa77da5 100644 --- a/lua/lazyvim/plugins/extras/lang/zig.lua +++ b/lua/lazyvim/plugins/extras/lang/zig.lua @@ -54,4 +54,38 @@ return { }, }, }, + { + "mfussenegger/nvim-dap", + optional = true, + opts = function() + local dap = require("dap") + dap.configurations.zig = { + { + name = "Zig Run", + type = "codelldb", + request = "launch", + program = function() + os.execute("zig build") + local command = "find ! -type d -path './zig-out/bin/*' | grep -v 'Test' | sed 's#.*/##'" + local bin_location = io.popen(command, "r") + if bin_location ~= nil then + return "zig-out/bin/" .. bin_location:read("*a"):gsub("[\n\r]", "") + else + return "" + end + end, + cwd = "${workspaceFolder}", + stopOnEntry = false, + args = function() + local argv = {} + arg = vim.fn.input(string.format("Arguments: ")) + for a in string.gmatch(arg, "%S+") do + table.insert(argv, a) + end + return argv + end, + }, + } + end, + }, }