94 lines
2.2 KiB
Lua
94 lines
2.2 KiB
Lua
local dap = require("dap")
|
|
local dapui = require("dapui")
|
|
|
|
dapui.setup({
|
|
layouts = {
|
|
{
|
|
position = "left",
|
|
size = 0.3,
|
|
elements = {
|
|
{ id = "scopes", size = 0.25 },
|
|
"stacks",
|
|
"watches",
|
|
"breakpoints",
|
|
},
|
|
},
|
|
{
|
|
position = "bottom",
|
|
size = 20,
|
|
elements = {
|
|
"repl",
|
|
},
|
|
},
|
|
}
|
|
})
|
|
|
|
dap.adapters.lldb = {
|
|
type = 'server',
|
|
host = '127.0.0.1',
|
|
port = "${port}",
|
|
executable = {
|
|
command = '/usr/bin/lldb-dap',
|
|
args = { "--port", "${port}" },
|
|
}
|
|
}
|
|
|
|
dap.configurations.rust = {
|
|
{
|
|
name = "Attach to Remote via GDB Remote",
|
|
type = "lldb",
|
|
request = "launch",
|
|
program = function()
|
|
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
|
|
end,
|
|
cwd = "${workspaceFolder}",
|
|
stopOnEntry = false,
|
|
|
|
initCommands = {
|
|
"gdb-remote localhost:1234",
|
|
},
|
|
}
|
|
}
|
|
|
|
-- dap.configurations.rust = {
|
|
-- {
|
|
-- name = "Launch File",
|
|
-- type = "codelldb",
|
|
-- request = "launch",
|
|
-- program = function()
|
|
-- return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
|
|
-- end,
|
|
-- cwd = '${workspaceFolder}',
|
|
-- runInTerminal = true,
|
|
-- stopOnEntry = false,
|
|
-- },
|
|
-- }
|
|
|
|
vim.keymap.set('n', '<Leader>dc', function() dap.continue() end)
|
|
vim.keymap.set('n', '<F10>', function() dap.step_over() end)
|
|
vim.keymap.set('n', '<F11>', function() dap.step_into() end)
|
|
vim.keymap.set('n', '<F12>', function() dap.step_out() end)
|
|
vim.keymap.set('n', '<Leader>db', function() dap.toggle_breakpoint() end)
|
|
vim.keymap.set('n', '<Leader>dl', function() dap.run_last() end)
|
|
vim.keymap.set('n', '<Leader>du', function() dapui.toggle() end)
|
|
vim.keymap.set('n', '<Leader>df', function() dapui.float_element('scopes', { enter = true }) 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
|
|
|
|
vim.api.nvim_create_autocmd("BufWritePost", {
|
|
pattern = "dapui-repl-*",
|
|
callback = function()
|
|
vim.cmd("AnsiEsc")
|
|
end,
|
|
})
|