Skip to content

Instantly share code, notes, and snippets.

@bus710
Last active August 18, 2024 04:58
Show Gist options
  • Save bus710/c3101ac5cef0cd1f19cce6944314bc6c to your computer and use it in GitHub Desktop.
Save bus710/c3101ac5cef0cd1f19cce6944314bc6c to your computer and use it in GitHub Desktop.
Debian + Zig + AstronNvim debugging configuration
-- 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,
}
@bus710
Copy link
Author

bus710 commented Jan 17, 2024

@bus710
Copy link
Author

bus710 commented Aug 18, 2024

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