first
This commit is contained in:
79
lua/plugins/debugger.lua
Normal file
79
lua/plugins/debugger.lua
Normal file
@@ -0,0 +1,79 @@
|
||||
return {
|
||||
{ "rcarriga/nvim-dap-ui", dependencies = {"mfussenegger/nvim-dap", "nvim-neotest/nvim-nio"},
|
||||
config = function ()
|
||||
local dap, dapui = require("dap"), require("dapui")
|
||||
|
||||
vim.keymap.set('n','<space>b', dap.toggle_breakpoint)
|
||||
vim.keymap.set('n','<space>gb', dap.run_to_cursor)
|
||||
|
||||
vim.keymap.set('n','<F1>', dap.continue)
|
||||
vim.keymap.set('n','<F2>', dap.step_into)
|
||||
vim.keymap.set('n','<F3>', dap.step_over)
|
||||
vim.keymap.set('n','<F4>', dap.step_out)
|
||||
vim.keymap.set('n','<F5>', dap.step_back)
|
||||
vim.keymap.set('n','<F6>', dap.restart)
|
||||
|
||||
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('dapui').setup()
|
||||
|
||||
end
|
||||
},
|
||||
{
|
||||
'mfussenegger/nvim-dap',
|
||||
config = function ()
|
||||
local dap = require("dap")
|
||||
dap.adapters.gdb = {
|
||||
type = "executable",
|
||||
command = "gdb",
|
||||
args = { "--interpreter=dap", "--eval-command", "set print pretty on" }
|
||||
}
|
||||
dap.configurations.c = {
|
||||
{
|
||||
name = "Launch",
|
||||
type = "gdb",
|
||||
request = "launch",
|
||||
program = function()
|
||||
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
|
||||
end,
|
||||
cwd = "${workspaceFolder}",
|
||||
stopAtBeginningOfMainSubprogram = false,
|
||||
},
|
||||
{
|
||||
name = "Select and attach to process",
|
||||
type = "gdb",
|
||||
request = "attach",
|
||||
program = function()
|
||||
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
|
||||
end,
|
||||
pid = function()
|
||||
local name = vim.fn.input('Executable name (filter): ')
|
||||
return require("dap.utils").pick_process({ filter = name })
|
||||
end,
|
||||
cwd = '${workspaceFolder}'
|
||||
},
|
||||
{
|
||||
|
||||
name = 'Attach to gdbserver :1234',
|
||||
type = 'gdb',
|
||||
request = 'attach',
|
||||
target = 'localhost:1234',
|
||||
program = function()
|
||||
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
|
||||
end,
|
||||
cwd = '${workspaceFolder}'
|
||||
},
|
||||
}
|
||||
end
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user