From fbcb8598a26dfc00a0bb9c3b7ec71e760da0907e Mon Sep 17 00:00:00 2001 From: aleidk Date: Thu, 24 Jul 2025 12:05:16 -0400 Subject: [PATCH] add debugger to nvim --- Configs/nvim/.config/nvim/lazy-lock.json | 3 + .../nvim/lua/aleidk/plugins/database.lua | 2 +- .../.config/nvim/lua/aleidk/plugins/debug.lua | 64 ++++++++++++++++++- .../.config/nvim/lua/aleidk/plugins/mini.lua | 13 ++++ 4 files changed, 80 insertions(+), 2 deletions(-) diff --git a/Configs/nvim/.config/nvim/lazy-lock.json b/Configs/nvim/.config/nvim/lazy-lock.json index 9fc7452..e91621d 100644 --- a/Configs/nvim/.config/nvim/lazy-lock.json +++ b/Configs/nvim/.config/nvim/lazy-lock.json @@ -4,6 +4,7 @@ "catppuccin": { "branch": "main", "commit": "56a9dfd1e05868cf3189369aad87242941396563" }, "comment-box.nvim": { "branch": "main", "commit": "06bb771690bc9df0763d14769b779062d8f12bc5" }, "conform.nvim": { "branch": "master", "commit": "6feb2f28f9a9385e401857b21eeac3c1b66dd628" }, + "dadbod-ui-yank": { "branch": "master", "commit": "b0fe1062485ce4fd44f4f41a1fe56090e7152843" }, "flatten.nvim": { "branch": "main", "commit": "72527798e75b5e34757491947c2cb853ce21dc0e" }, "friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" }, "fzf-lua": { "branch": "main", "commit": "758173f499d15410ecb50c5519a41b27c33e645d" }, @@ -15,6 +16,8 @@ "mini.nvim": { "branch": "main", "commit": "94cae4660a8b2d95dbbd56e1fbc6fcfa2716d152" }, "neogen": { "branch": "main", "commit": "b2e78708876f4da507839726816010a68e33fec8" }, "nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" }, + "nvim-dap": { "branch": "master", "commit": "5dd4d50f2e6a2eaf9e57fad023d294ef371bda35" }, + "nvim-dap-view": { "branch": "main", "commit": "390dae6bf67f3342ebb481159932ef0fe54822ba" }, "nvim-lint": { "branch": "master", "commit": "b47cbb249351873e3a571751c3fb66ed6369852f" }, "nvim-lspconfig": { "branch": "master", "commit": "b8e7957bde4cbb3cb25a13a62548f7c273b026e9" }, "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, diff --git a/Configs/nvim/.config/nvim/lua/aleidk/plugins/database.lua b/Configs/nvim/.config/nvim/lua/aleidk/plugins/database.lua index 9a942cb..8571340 100644 --- a/Configs/nvim/.config/nvim/lua/aleidk/plugins/database.lua +++ b/Configs/nvim/.config/nvim/lua/aleidk/plugins/database.lua @@ -11,7 +11,7 @@ return { { "DBUIFindBuffer", }, keys = { - { "ud", "DBUIToggle", desc = "Toggle DB UI" }, + { "uD", "DBUIToggle", desc = "Toggle DB UI" }, }, init = function() -- Your DBUI configuration diff --git a/Configs/nvim/.config/nvim/lua/aleidk/plugins/debug.lua b/Configs/nvim/.config/nvim/lua/aleidk/plugins/debug.lua index 3dd6907..cc0c78b 100644 --- a/Configs/nvim/.config/nvim/lua/aleidk/plugins/debug.lua +++ b/Configs/nvim/.config/nvim/lua/aleidk/plugins/debug.lua @@ -6,8 +6,70 @@ return { "igorlfs/nvim-dap-view", ---@module 'dap-view' ---@type dapview.Config - opts = {}, + opts = { + auto_toggle = true, + switchbuf = "useopen,uselast", + winbar = { + sections = { "watches", "scopes", "breakpoints", "repl", "console" }, + controls = { + enabled = true, + }, + }, + windows = { + terminal = { + start_hidden = true, + } + } + }, }, + }, + config = function() + require("dap").adapters.codelldb = { + type = "executable", + command = "codelldb", + } + end, + keys = { + { + "dd", + function() + local dap = require("dap") + if dap.status() == "" then + dap.run_last() + else + dap.restart() + end + end, + desc = "Run last or restart debugger" + }, + { "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 = "Conditional Breakpoint", + }, + { "dw", function() require("dap-view").add_expr() end, desc = "Watch expresion under cursor", mode = { "n", "v" } }, + { + "dW", + function() + vim.ui.input({ prompt = "Watch expresion: " }, function(input) + require("dap-view").add_expr(input) + end) + end, + desc = "Watch expression", + }, + { "dj", function() require("dap").step_over() end, desc = "Step over" }, + { "dJ", function() require("dap").continue() end, desc = "Continue" }, + { "dl", function() require("dap").step_into() end, desc = "Step into" }, + { "dk", function() require("dap").step_out() end, desc = "Step out" }, + { "dh", function() require("dap.ui.widgets").hover() end, desc = "Show expresion under cursor" }, + { "dx", function() require("dap").clear_breakpoints() end, desc = "Clear breakpoint" }, + { "dX", function() require("dap").terminate() end, desc = "Terminate" }, + { "ud", function() require("dap-view").toggle(true) end, desc = "Toggle dap-view" }, } } } diff --git a/Configs/nvim/.config/nvim/lua/aleidk/plugins/mini.lua b/Configs/nvim/.config/nvim/lua/aleidk/plugins/mini.lua index 4450c78..d9d304b 100644 --- a/Configs/nvim/.config/nvim/lua/aleidk/plugins/mini.lua +++ b/Configs/nvim/.config/nvim/lua/aleidk/plugins/mini.lua @@ -6,6 +6,14 @@ return { }, config = function() require('mini.icons').setup() + + vim.fn.sign_define("DapBreakpoint", { text = " ", texthl = "DapBreakpoint" }) + vim.fn.sign_define("DapBreakpointCondition", { text = " ", texthl = "DapBreakpointCondition" }) + vim.fn.sign_define("DapBreakpointRejected", { text = " ", texthl = "DapBreakpointRejected" }) + vim.fn.sign_define("DapLogPoint", { text = ".>", texthl = "DapLogPoint" }) + vim.fn.sign_define("DapStopped", { text = "󰁕 ", texthl = "DapStopped", numhl = "debugPC" }) + + require('mini.bracketed').setup({ diagnostic = { options = { severity = vim.diagnostic.severity.ERROR } }, }) @@ -139,6 +147,11 @@ return { { mode = "n", keys = "b", desc = "+Buffers" }, { mode = "n", keys = "bh", postkeys = "b" }, { mode = "n", keys = "bl", postkeys = "b" }, + { mode = "n", keys = "d", desc = "+Debugger" }, + { mode = "n", keys = "dh", postkeys = "d" }, + { mode = "n", keys = "dj", postkeys = "d" }, + { mode = "n", keys = "dk", postkeys = "d" }, + { mode = "n", keys = "dl", postkeys = "d" }, { mode = "n", keys = "f", desc = "+Find" }, { mode = "n", keys = "g", desc = "+Git" }, { mode = "n", keys = "l", desc = "+LSP" },