From a09e5f53c14478f99a1a7047cb2d46ce6a80c0ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20S=C3=A4ume?= Date: Thu, 30 May 2024 16:31:02 +0200 Subject: [PATCH] Add Go Debugger --- .config/nvim/dependencies.dnf.txt | 2 +- .../plugins/editor/debugger/debugger_go.lua | 6 ++ .../lua/plugins/editor/editor_debugging.lua | 102 ++++++++++-------- 3 files changed, 67 insertions(+), 43 deletions(-) create mode 100644 .config/nvim/lua/plugins/editor/debugger/debugger_go.lua diff --git a/.config/nvim/dependencies.dnf.txt b/.config/nvim/dependencies.dnf.txt index 121b303..87ecbda 100644 --- a/.config/nvim/dependencies.dnf.txt +++ b/.config/nvim/dependencies.dnf.txt @@ -1 +1 @@ -neovim lua gcc curl wget git unzip tar gzip ripgrep php composer go nodejs npm \ No newline at end of file +neovim lua gcc curl wget git unzip tar gzip ripgrep php composer go nodejs npm delve diff --git a/.config/nvim/lua/plugins/editor/debugger/debugger_go.lua b/.config/nvim/lua/plugins/editor/debugger/debugger_go.lua new file mode 100644 index 0000000..b21dd1a --- /dev/null +++ b/.config/nvim/lua/plugins/editor/debugger/debugger_go.lua @@ -0,0 +1,6 @@ +return { + "leoluz/nvim-dap-go", + config = function() + require("dap-go").setup() + end +} diff --git a/.config/nvim/lua/plugins/editor/editor_debugging.lua b/.config/nvim/lua/plugins/editor/editor_debugging.lua index b286ae0..1ff515e 100644 --- a/.config/nvim/lua/plugins/editor/editor_debugging.lua +++ b/.config/nvim/lua/plugins/editor/editor_debugging.lua @@ -1,57 +1,75 @@ return { - "mfussenegger/nvim-dap", - dependencies = { - "rcarriga/nvim-dap-ui", - "nvim-neotest/nvim-nio", - }, - config = function() - -- Setup Debugging -- - local dap = require("dap") + { + "mfussenegger/nvim-dap", + dependencies = { + "rcarriga/nvim-dap-ui", + "nvim-neotest/nvim-nio", + }, + config = function() + -- Setup Debugging -- + local dap = require("dap") - -- Open UI on Debugging -- - local dapui = require("dapui").setup() - 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 + -- Open UI on Debugging -- + local dapui = require("dapui") + dapui.setup({ + layouts = { + { + elements = { + { id = "scopes", size = 0.65 }, + { id = "breakpoints", size = 0.35 }, + }, + position = "left", + size = 40, + }, + { + elements = { + { id = "repl", size = 0.5 }, + { id = "console", size = 0.5 }, + }, + position = "bottom", + size = 10, + }, + }, + }) + dap.listeners.before.attach.dapui_config = function() + dapui.open() + end + dap.listeners.before.launch.dapui_config = function() + dapui.open() + end - -- Keybinding -- - vim.keymap.set("n", "db", dap.toggle_breakpoint, { desc = "Toggle Breakpoint" }) - vim.keymap.set("n", "dc", dap.continue, { desc = "Debugger Continue" }) - vim.keymap.set("n", "dx", dap.terminate, { desc = "Debugger Terminate" }) - vim.keymap.set("n", "ds", dap.step_over, { desc = "Debugger Step Over" }) + -- Keybinding -- + vim.keymap.set("n", "dt", dapui.toggle, { desc = "Toggle Debugger UI" }) + vim.keymap.set("n", "db", dap.toggle_breakpoint, { desc = "Toggle Breakpoint" }) + vim.keymap.set("n", "dc", dap.continue, { desc = "Debugger Continue" }) + vim.keymap.set("n", "dx", dap.terminate, { desc = "Debugger Terminate" }) + vim.keymap.set("n", "ds", dap.step_over, { desc = "Debugger Step Over" }) - -- Breakpoints -- - vim.api.nvim_set_hl(0, "DapBreakpoint", { ctermbg = 0, fg = "#993939", bg = "#31353f" }) - vim.api.nvim_set_hl(0, "DapLogPoint", { ctermbg = 0, fg = "#61afef", bg = "#31353f" }) - vim.api.nvim_set_hl(0, "DapStopped", { ctermbg = 0, fg = "#98c379", bg = "#31353f" }) - vim.fn.sign_define( + -- Breakpoints -- + vim.api.nvim_set_hl(0, "DapBreakpoint", { ctermbg = 0, fg = "#993939", bg = "#31353f" }) + vim.api.nvim_set_hl(0, "DapLogPoint", { ctermbg = 0, fg = "#61afef", bg = "#31353f" }) + vim.api.nvim_set_hl(0, "DapStopped", { ctermbg = 0, fg = "#98c379", bg = "#31353f" }) + vim.fn.sign_define( "DapBreakpoint", { text = "", texthl = "DapBreakpoint", linehl = "DapBreakpoint", numhl = "DapBreakpoint" } - ) - vim.fn.sign_define( + ) + vim.fn.sign_define( "DapBreakpointCondition", { text = "󰣏", texthl = "DapBreakpoint", linehl = "DapBreakpoint", numhl = "DapBreakpoint" } - ) - vim.fn.sign_define( + ) + vim.fn.sign_define( "DapBreakpointRejected", { text = "", texthl = "DapBreakpoint", linehl = "DapBreakpoint", numhl = "DapBreakpoint" } - ) - vim.fn.sign_define( + ) + vim.fn.sign_define( "DapLogPoint", { text = "", texthl = "DapLogPoint", linehl = "DapLogPoint", numhl = "DapLogPoint" } - ) - vim.fn.sign_define( + ) + vim.fn.sign_define( "DapStopped", { text = "", texthl = "DapStopped", linehl = "DapStopped", numhl = "DapStopped" } - ) - end, + ) + end, + }, + require("plugins.editor.debugger.debugger_go"), }