nvim: Extract debug plugins into debug module
This commit is contained in:
parent
020ec86481
commit
51595b8b81
2 changed files with 159 additions and 96 deletions
159
nvim/.config/nvim/lua/plugins/debug.lua
Normal file
159
nvim/.config/nvim/lua/plugins/debug.lua
Normal file
|
|
@ -0,0 +1,159 @@
|
|||
return {
|
||||
{
|
||||
"mfussenegger/nvim-dap",
|
||||
init = function()
|
||||
if require("core.util").is_available("which-key") then
|
||||
require("which-key").add({ "<localleader>d", group = "debug" })
|
||||
end
|
||||
end,
|
||||
dependencies = {
|
||||
{
|
||||
"LiadOz/nvim-dap-repl-highlights",
|
||||
opts = {},
|
||||
build = ":TSInstall dap_repl",
|
||||
dependencies = { "nvim-treesitter/nvim-treesitter" },
|
||||
},
|
||||
{
|
||||
"igorlfs/nvim-dap-view",
|
||||
opts = { winbar = { controls = { enabled = true } } },
|
||||
keys = {
|
||||
{
|
||||
"<leader>sb",
|
||||
function()
|
||||
require("dap-view").toggle()
|
||||
end,
|
||||
desc = "Dap UI",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
config = function()
|
||||
local dap, dv = require("dap"), require("dap-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
|
||||
-- Signs
|
||||
for _, group in pairs({
|
||||
"DapBreakpoint",
|
||||
"DapBreakpointCondition",
|
||||
"DapBreakpointRejected",
|
||||
"DapLogPoint",
|
||||
}) do
|
||||
vim.fn.sign_define(group, { text = "●", texthl = group })
|
||||
end
|
||||
vim.fn.sign_define("DapStopped", { text = "", texthl = "DapStopped", numhl = "debugPC" })
|
||||
-- jump to stopped-at breakpoint if it is visible in a tab or open a new tab
|
||||
require("dap").defaults.fallback.switchbuf = "usevisible,usetab,newtab"
|
||||
end,
|
||||
keys = {
|
||||
{
|
||||
"<localleader>dc",
|
||||
function()
|
||||
require("dap").continue()
|
||||
end,
|
||||
desc = "continue",
|
||||
},
|
||||
{
|
||||
"<localleader>dt",
|
||||
function()
|
||||
require("dap").terminate()
|
||||
end,
|
||||
desc = "terminate",
|
||||
},
|
||||
{
|
||||
"<localleader>dr",
|
||||
function()
|
||||
require("dap").run_to_cursor()
|
||||
end,
|
||||
desc = "run to cursor",
|
||||
},
|
||||
{
|
||||
"<localleader>dj",
|
||||
function()
|
||||
require("dap").step_over()
|
||||
end,
|
||||
desc = "step over",
|
||||
},
|
||||
{
|
||||
"<localleader>dl",
|
||||
function()
|
||||
require("dap").step_into()
|
||||
end,
|
||||
desc = "step into",
|
||||
},
|
||||
{
|
||||
"<localleader>dh",
|
||||
function()
|
||||
require("dap").step_out()
|
||||
end,
|
||||
desc = "step out",
|
||||
},
|
||||
{
|
||||
"<localleader>[d",
|
||||
function()
|
||||
require("dap").up()
|
||||
end,
|
||||
desc = "DAP up",
|
||||
},
|
||||
{
|
||||
"<localleader>]d",
|
||||
function()
|
||||
require("dap").down()
|
||||
end,
|
||||
desc = "DAP down",
|
||||
},
|
||||
|
||||
{
|
||||
"<localleader>db",
|
||||
function()
|
||||
require("dap").toggle_breakpoint()
|
||||
end,
|
||||
desc = "toggle breakpoint",
|
||||
},
|
||||
{
|
||||
"<localleader>dB",
|
||||
function()
|
||||
vim.ui.input({ prompt = "Breakpoint condition: " }, function(input)
|
||||
require("dap").set_breakpoint(input)
|
||||
end)
|
||||
end,
|
||||
desc = "set logpoint",
|
||||
},
|
||||
{
|
||||
"<localleader>dL",
|
||||
function()
|
||||
vim.ui.input({ prompt = "Log point message: " }, function(input)
|
||||
require("dap").set_breakpoint(nil, nil, input)
|
||||
end)
|
||||
end,
|
||||
desc = "set logpoint",
|
||||
},
|
||||
|
||||
{
|
||||
"<localleader>dk",
|
||||
function()
|
||||
require("dap.ui.widgets").hover()
|
||||
end,
|
||||
desc = "hover",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
"mfussenegger/nvim-dap-python",
|
||||
dependencies = { { "mfussenegger/nvim-dap", optional = true } },
|
||||
ft = { "python" },
|
||||
config = function()
|
||||
require("dap-python").setup("debugpy-adapter")
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
|
@ -149,100 +149,4 @@ return {
|
|||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
"mfussenegger/nvim-dap",
|
||||
init = function()
|
||||
if require("core.util").is_available("which-key") then
|
||||
require("which-key").add({ "<localleader>d", group = "debug" })
|
||||
end
|
||||
end,
|
||||
dependencies = {
|
||||
{
|
||||
"LiadOz/nvim-dap-repl-highlights",
|
||||
opts = {},
|
||||
build = ":TSInstall dap_repl",
|
||||
dependencies = { "nvim-treesitter/nvim-treesitter" },
|
||||
},
|
||||
{
|
||||
"igorlfs/nvim-dap-view",
|
||||
opts = { winbar = { controls = { enabled = true } } },
|
||||
keys = {
|
||||
{
|
||||
"<leader>sb",
|
||||
function()
|
||||
require("dap-view").toggle()
|
||||
end,
|
||||
desc = "Dap UI",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
config = function()
|
||||
local dap, dv = require("dap"), require("dap-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
|
||||
-- Signs
|
||||
for _, group in pairs({
|
||||
"DapBreakpoint",
|
||||
"DapBreakpointCondition",
|
||||
"DapBreakpointRejected",
|
||||
"DapLogPoint",
|
||||
}) do
|
||||
vim.fn.sign_define(group, { text = "●", texthl = group })
|
||||
end
|
||||
vim.fn.sign_define("DapStopped", { text = "", texthl = "DapStopped", numhl = "debugPC" })
|
||||
-- jump to stopped-at breakpoint if it is visible in a tab or open a new tab
|
||||
require("dap").defaults.fallback.switchbuf = "usevisible,usetab,newtab"
|
||||
end,
|
||||
keys = {
|
||||
{ "<localleader>dc", function() require("dap").continue() end, desc = "continue" },
|
||||
{ "<localleader>dt", function() require("dap").terminate() end, desc = "terminate" },
|
||||
{ "<localleader>dr", function() require("dap").run_to_cursor() end, desc = "run to cursor" },
|
||||
{ "<localleader>dj", function() require("dap").step_over() end, desc = "step over" },
|
||||
{ "<localleader>dl", function() require("dap").step_into() end, desc = "step into" },
|
||||
{ "<localleader>dh", function() require("dap").step_out() end, desc = "step out" },
|
||||
{ "<localleader>[d", function() require("dap").up() end, desc = "DAP up" },
|
||||
{ "<localleader>]d", function() require("dap").down() end, desc = "DAP down" },
|
||||
|
||||
{ "<localleader>db", function() require("dap").toggle_breakpoint() end, desc = "toggle breakpoint" },
|
||||
{
|
||||
"<localleader>dB",
|
||||
function()
|
||||
vim.ui.input({ prompt = "Breakpoint condition: " }, function(input)
|
||||
require("dap").set_breakpoint(input)
|
||||
end)
|
||||
end,
|
||||
desc = "set logpoint",
|
||||
},
|
||||
{
|
||||
"<localleader>dL",
|
||||
function()
|
||||
vim.ui.input({ prompt = "Log point message: " }, function(input)
|
||||
require("dap").set_breakpoint(nil, nil, input)
|
||||
end)
|
||||
end,
|
||||
desc = "set logpoint",
|
||||
},
|
||||
|
||||
{ "<localleader>dk", function() require("dap.ui.widgets").hover() end, desc = "hover" },
|
||||
},
|
||||
},
|
||||
{
|
||||
"mfussenegger/nvim-dap-python",
|
||||
dependencies = { { "mfussenegger/nvim-dap", optional = true } },
|
||||
ft = { "python" },
|
||||
config = function()
|
||||
require("dap-python").setup("debugpy-adapter")
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue