Last active
August 18, 2024 04:58
-
-
Save bus710/c3101ac5cef0cd1f19cce6944314bc6c to your computer and use it in GitHub Desktop.
Debian + Zig + AstronNvim debugging configuration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Should be placed in the plugins directory. | |
return { | |
"mfussenegger/nvim-dap", | |
config = function() | |
local dap, dapui = require "dap", require "dapui" | |
dap.adapters.lldb = { | |
type = 'executable', | |
command = '/usr/bin/lldb-vscode-16', | |
name = 'lldb' | |
} | |
dap.configurations.zig = { | |
{ | |
name = 'Launch', | |
type = 'lldb', | |
request = 'launch', | |
program = '${workspaceFolder}/zig-out/bin/${workspaceFolderBasename}', | |
cwd = '${workspaceFolder}', | |
stopOnEntry = false, | |
args = {}, | |
} | |
} | |
dap.listeners.after.event_initialized["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 | |
end, | |
} |
The config ended up being like this:
local dap = require "dap"
local dapui = require "dapui"
function getcwdtail()
return vim.fn.fnamemodify(vim.fn.getcwd(), ':t')
end
dap.adapters.lldb = {
type = "executable",
command = "/usr/bin/lldb-vscode-16",
name = "lldb",
}
dap.configurations.zig = {
{
name = "LLDB: Launch Custom",
type = "lldb",
request = "launch",
program = "${workspaceFolder}/zig-out/bin/" .. getcwdtail(),
-- program = function()
-- return vim.fn.input(
-- 'Path to executable for Zig: ',
-- vim.fn.getcwd() .. '/zig-out/bin/' .. getcwdtail(),
-- 'file')
-- end,
cwd = "${workspaceFolder}",
stopOnEntry = false,
args = {},
runInTerminal = false,
},
}
dap.listeners.after.event_initialized["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
return {}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Many thanks to https://terminalprogrammer.com/neovim-setup-for-zig