116 lines
3.0 KiB
Lua
116 lines
3.0 KiB
Lua
return {
|
|
"mfussenegger/nvim-dap",
|
|
dependencies = {
|
|
"rcarriga/nvim-dap-ui",
|
|
"nvim-neotest/nvim-nio",
|
|
"theHamsta/nvim-dap-virtual-text",
|
|
"Weissle/persistent-breakpoints.nvim",
|
|
},
|
|
config = function()
|
|
local dap, dapui = require("dap"), require("dapui")
|
|
dapui.setup({})
|
|
dap.adapters = {
|
|
lldb = {
|
|
type = "executable",
|
|
command = "/usr/bin/lldb-dap",
|
|
name = "lldb",
|
|
},
|
|
codelldb = {
|
|
type = "executable",
|
|
command = "codelldb",
|
|
name = "codelldb",
|
|
},
|
|
}
|
|
local pickers = require("telescope.pickers")
|
|
local finders = require("telescope.finders")
|
|
local conf = require("telescope.config").values
|
|
local actions = require("telescope.actions")
|
|
local action_state = require("telescope.actions.state")
|
|
dap.configurations = {
|
|
cpp = {
|
|
{
|
|
name = "Launch file(codelldb)",
|
|
type = "codelldb",
|
|
request = "launch",
|
|
program = function()
|
|
return coroutine.create(function(coro)
|
|
local opts = {}
|
|
pickers
|
|
.new(opts, {
|
|
prompt_title = "Path to executable",
|
|
finder = finders.new_oneshot_job(
|
|
{ "fd", "--hidden", "--no-ignore", "--type", "x" },
|
|
{}
|
|
),
|
|
sorter = conf.generic_sorter(opts),
|
|
attach_mappings = function(buffer_number)
|
|
actions.select_default:replace(function()
|
|
actions.close(buffer_number)
|
|
coroutine.resume(coro, action_state.get_selected_entry()[1])
|
|
end)
|
|
return true
|
|
end,
|
|
})
|
|
:find()
|
|
end)
|
|
end,
|
|
cwd = "${workspaceFolder}",
|
|
stopOnEntry = false,
|
|
},
|
|
{
|
|
name = "Launch(lldb-dap)",
|
|
type = "lldb",
|
|
request = "launch",
|
|
program = function()
|
|
return coroutine.create(function(coro)
|
|
local opts = {}
|
|
pickers
|
|
.new(opts, {
|
|
prompt_title = "Path to executable",
|
|
finder = finders.new_oneshot_job(
|
|
{ "fd", "--hidden", "--no-ignore", "--type", "x" },
|
|
{}
|
|
),
|
|
sorter = conf.generic_sorter(opts),
|
|
attach_mappings = function(buffer_number)
|
|
actions.select_default:replace(function()
|
|
actions.close(buffer_number)
|
|
coroutine.resume(coro, action_state.get_selected_entry()[1])
|
|
end)
|
|
return true
|
|
end,
|
|
})
|
|
:find()
|
|
end)
|
|
end,
|
|
cwd = "${workspaceFolder}",
|
|
stopOnEntry = false,
|
|
args = {},
|
|
env = function()
|
|
local variables = {}
|
|
for k, v in pairs(vim.fn.environ()) do
|
|
table.insert(variables, string.format("%s=%s", k, v))
|
|
end
|
|
return variables
|
|
end,
|
|
},
|
|
},
|
|
}
|
|
dap.listeners.before.attach.dapui_config = function()
|
|
dapui.open()
|
|
end
|
|
dap.listeners.before.launch.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
|
|
require("persistent-breakpoints").setup({
|
|
load_breakpoints_event = { "BufReadPost" },
|
|
})
|
|
end,
|
|
}
|