mirror of
https://github.com/kossLAN/nvim-flake.git
synced 2025-11-05 02:09:49 -05:00
dap: add dapui & add lldb-dap support
This commit is contained in:
parent
c4de9207c0
commit
3784061378
4 changed files with 67 additions and 36 deletions
|
|
@ -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 = {
|
||||
type = 'executable',
|
||||
command = 'gdb',
|
||||
args = { '-i', 'dap' },
|
||||
}
|
||||
|
||||
dap.configurations.c = {
|
||||
{
|
||||
name = 'Launch',
|
||||
type = 'gdb',
|
||||
request = 'launch',
|
||||
program = function()
|
||||
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
|
||||
end,
|
||||
stopAtBeginningOfMainSubprogram = false,
|
||||
dap.adapters = {
|
||||
lldb = {
|
||||
type = 'executable',
|
||||
command = get_binary_path('lldb-dap'),
|
||||
name = 'lldb',
|
||||
},
|
||||
gdb = {
|
||||
type = 'executable',
|
||||
command = 'gdb',
|
||||
args = { '-i', 'dap' },
|
||||
},
|
||||
}
|
||||
|
||||
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,
|
||||
},
|
||||
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,
|
||||
cwd = '${workspaceFolder}',
|
||||
}
|
||||
|
||||
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue