diff --git a/nvim/.config/nvim/lua/plugins/debug.lua b/nvim/.config/nvim/lua/plugins/debug.lua new file mode 100644 index 0000000..7812fc8 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/debug.lua @@ -0,0 +1,159 @@ +return { + { + "mfussenegger/nvim-dap", + init = function() + if require("core.util").is_available("which-key") then + require("which-key").add({ "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 = { + { + "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 = { + { + "dc", + function() + require("dap").continue() + end, + desc = "continue", + }, + { + "dt", + function() + require("dap").terminate() + end, + desc = "terminate", + }, + { + "dr", + function() + require("dap").run_to_cursor() + end, + desc = "run to cursor", + }, + { + "dj", + function() + require("dap").step_over() + end, + desc = "step over", + }, + { + "dl", + function() + require("dap").step_into() + end, + desc = "step into", + }, + { + "dh", + function() + require("dap").step_out() + end, + desc = "step out", + }, + { + "[d", + function() + require("dap").up() + end, + desc = "DAP up", + }, + { + "]d", + function() + require("dap").down() + end, + desc = "DAP down", + }, + + { + "db", + function() + require("dap").toggle_breakpoint() + end, + desc = "toggle breakpoint", + }, + { + "dB", + function() + vim.ui.input({ prompt = "Breakpoint condition: " }, function(input) + require("dap").set_breakpoint(input) + end) + end, + desc = "set logpoint", + }, + { + "dL", + function() + vim.ui.input({ prompt = "Log point message: " }, function(input) + require("dap").set_breakpoint(nil, nil, input) + end) + end, + desc = "set logpoint", + }, + + { + "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, + }, +} diff --git a/nvim/.config/nvim/lua/plugins/testing.lua b/nvim/.config/nvim/lua/plugins/testing.lua index edb9967..70e3670 100644 --- a/nvim/.config/nvim/lua/plugins/testing.lua +++ b/nvim/.config/nvim/lua/plugins/testing.lua @@ -149,100 +149,4 @@ return { }, }, }, - { - "mfussenegger/nvim-dap", - init = function() - if require("core.util").is_available("which-key") then - require("which-key").add({ "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 = { - { - "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 = { - { "dc", function() require("dap").continue() end, desc = "continue" }, - { "dt", function() require("dap").terminate() end, desc = "terminate" }, - { "dr", function() require("dap").run_to_cursor() end, desc = "run to cursor" }, - { "dj", function() require("dap").step_over() end, desc = "step over" }, - { "dl", function() require("dap").step_into() end, desc = "step into" }, - { "dh", function() require("dap").step_out() end, desc = "step out" }, - { "[d", function() require("dap").up() end, desc = "DAP up" }, - { "]d", function() require("dap").down() end, desc = "DAP down" }, - - { "db", function() require("dap").toggle_breakpoint() end, desc = "toggle breakpoint" }, - { - "dB", - function() - vim.ui.input({ prompt = "Breakpoint condition: " }, function(input) - require("dap").set_breakpoint(input) - end) - end, - desc = "set logpoint", - }, - { - "dL", - function() - vim.ui.input({ prompt = "Log point message: " }, function(input) - require("dap").set_breakpoint(nil, nil, input) - end) - end, - desc = "set logpoint", - }, - - { "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, - }, }