dap: add dapui & add lldb-dap support

This commit is contained in:
kossLAN 2024-11-17 03:59:26 -05:00
parent c4de9207c0
commit 3784061378
Signed by: kossLAN
SSH key fingerprint: SHA256:bdV0x+wdQHGJ6LgmstH3KV8OpWY+OOFmJcPcB0wQPV8
4 changed files with 67 additions and 36 deletions

12
flake.lock generated
View file

@ -39,11 +39,11 @@
"systems": "systems"
},
"locked": {
"lastModified": 1726560853,
"narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=",
"lastModified": 1731533236,
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a",
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
"type": "github"
},
"original": {
@ -181,11 +181,11 @@
},
"nixpkgs_2": {
"locked": {
"lastModified": 1730531603,
"narHash": "sha256-Dqg6si5CqIzm87sp57j5nTaeBbWhHFaVyG7V6L8k3lY=",
"lastModified": 1731676054,
"narHash": "sha256-OZiZ3m8SCMfh3B6bfGC/Bm4x3qc1m2SVEAlkV6iY7Yg=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "7ffd9ae656aec493492b44d0ddfb28e79a1ea25d",
"rev": "5e4fbfb6b3de1aa2872b76d49fafc942626e2add",
"type": "github"
},
"original": {

View file

@ -87,6 +87,7 @@ with final.pkgs.lib; let
mini-nvim # https://github.com/echasnovski/mini.nvim/
# Debugging
nvim-dap
nvim-dap-ui
# Notifications
nvim-notify
fidget-nvim
@ -113,10 +114,6 @@ with final.pkgs.lib; let
rustfmt # rust formatter
prettierd # typescript/javascript formatter
# google-java-format # java formatter based off google guidelines
# misc
nodejs # eww
gcc
];
in {
# This is the neovim derivation

View file

@ -52,7 +52,6 @@ vim.schedule(function()
end)
-- Configure Neovim diagnostic messages
local function prefix_diagnostic(prefix, diagnostic)
return string.format(prefix .. ' %s', diagnostic.message)
end

View file

@ -1,30 +1,65 @@
-- For some reason this nvim-dap doesn't wan't to find lldb-dap executable...
local function get_binary_path(binary)
local handle = io.popen('whereis -b ' .. binary .. ' | cut -d" " -f2')
if handle then
local result = handle:read('*a')
handle:close()
return result:gsub('\n', '') -- Remove trailing newline
end
return nil
end
local dap = require('dap')
dap.adapters.gdb = {
dap.adapters = {
lldb = {
type = 'executable',
command = get_binary_path('lldb-dap'),
name = 'lldb',
},
gdb = {
type = 'executable',
command = 'gdb',
args = { '-i', 'dap' },
},
}
dap.configurations.c = {
{
name = 'Launch',
local lldb = {
name = 'lldb',
type = 'lldb',
request = 'launch',
program = function()
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
end,
cwd = '${workspaceFolder}',
stopOnEntry = false,
args = {},
runInTerminal = true,
}
local gdb = {
name = 'gdb',
type = 'gdb',
request = 'launch',
program = function()
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
end,
stopAtBeginningOfMainSubprogram = false,
},
cwd = '${workspaceFolder}',
}
dap.configurations.cpp = {
{
name = 'Launch',
type = 'gdb',
request = 'launch',
program = function()
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
end,
stopAtBeginningOfMainSubprogram = false,
},
}
dap.configurations.c = { lldb, gdb }
dap.configurations.cpp = { lldb, gdb }
dap.configurations.rust = lldb
-- DAP UI
local dapui = require('dapui')
dapui.setup()
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