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

View file

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

View file

@ -52,7 +52,6 @@ vim.schedule(function()
end) end)
-- Configure Neovim diagnostic messages -- Configure Neovim diagnostic messages
local function prefix_diagnostic(prefix, diagnostic) local function prefix_diagnostic(prefix, diagnostic)
return string.format(prefix .. ' %s', diagnostic.message) return string.format(prefix .. ' %s', diagnostic.message)
end 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') local dap = require('dap')
dap.adapters.gdb = { dap.adapters = {
lldb = {
type = 'executable',
command = get_binary_path('lldb-dap'),
name = 'lldb',
},
gdb = {
type = 'executable', type = 'executable',
command = 'gdb', command = 'gdb',
args = { '-i', 'dap' }, args = { '-i', 'dap' },
},
} }
dap.configurations.c = { local lldb = {
{ name = 'lldb',
name = 'Launch', 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', type = 'gdb',
request = 'launch', request = 'launch',
program = function() program = function()
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
end, end,
stopAtBeginningOfMainSubprogram = false, cwd = '${workspaceFolder}',
},
} }
dap.configurations.cpp = { dap.configurations.c = { lldb, gdb }
{ dap.configurations.cpp = { lldb, gdb }
name = 'Launch', dap.configurations.rust = lldb
type = 'gdb',
request = 'launch', -- DAP UI
program = function() local dapui = require('dapui')
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') dapui.setup()
end,
stopAtBeginningOfMainSubprogram = 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