add dap plugin, remove old keymaps
This commit is contained in:
parent
9379ce6b40
commit
6e884786ed
2 changed files with 100 additions and 14 deletions
100
lua/plugin/dap.lua
Normal file
100
lua/plugin/dap.lua
Normal file
|
@ -0,0 +1,100 @@
|
|||
return {
|
||||
{
|
||||
"mfussenegger/nvim-dap",
|
||||
dependencies = {
|
||||
"igorlfs/nvim-dap-view",
|
||||
opts = {
|
||||
windows = {
|
||||
terminal = {
|
||||
hide = { "c" },
|
||||
start_hidden = true,
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
config = function()
|
||||
local dap, dv = require("dap"), require("dap-view")
|
||||
|
||||
dap.set_log_level("DEBUG")
|
||||
vim.keymap.set("n", "<Leader>Dc", dap.continue, { desc = "Debug: Continue" })
|
||||
vim.keymap.set("n", "<Leader>Dsn", dap.step_over, { desc = "Debug: Step Over (Next)" })
|
||||
vim.keymap.set("n", "<Leader>Dsi", dap.step_into, { desc = "Debug: Step Into" })
|
||||
vim.keymap.set("n", "<Leader>Dso", dap.step_out, { desc = "Debug: Step Out" })
|
||||
vim.keymap.set("n", "<Leader>B", dap.toggle_breakpoint, { desc = "Debug: Toggle Breakpoint" })
|
||||
vim.keymap.set("n", "<Leader>Dv", "<cmd>DapViewToggle<cr>", { desc = "Debug: Toggle Debug View" })
|
||||
|
||||
dap.listeners.before.attach["dap-view-config"] = function()
|
||||
dv.open()
|
||||
end
|
||||
dap.listeners.before.launch["dap-view-config"] = function()
|
||||
dv.open()
|
||||
end
|
||||
dap.listeners.before.event_terminated["dap-view-config"] = function()
|
||||
dv.close()
|
||||
end
|
||||
dap.listeners.before.event_exited["dap-view-config"] = function()
|
||||
dv.close()
|
||||
end
|
||||
|
||||
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,
|
||||
},
|
||||
{
|
||||
"jay-babu/mason-nvim-dap.nvim",
|
||||
dependencies = {
|
||||
"mfussenegger/nvim-dap",
|
||||
"williamboman/mason.nvim",
|
||||
},
|
||||
config = function()
|
||||
require('mason-nvim-dap').setup({
|
||||
handlers = {
|
||||
function(config)
|
||||
-- all sources with no handler get passed here
|
||||
|
||||
-- Keep original functionality
|
||||
require('mason-nvim-dap').default_setup(config)
|
||||
end,
|
||||
},
|
||||
})
|
||||
end,
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue