From c8d77a36de3a6a9e9696f7f1d44bde0f2bcbcc19 Mon Sep 17 00:00:00 2001 From: Martin Lasson Date: Thu, 10 Apr 2025 21:05:41 +0200 Subject: [PATCH] Switch back to nvim-dap-ui from dap-view, additionally, add keybind for opening a float with the console output --- nvim/lazy-lock.json | 2 +- nvim/lua/plugs/nvim-dap.lua | 49 ++++++++++++++++++++++++++++++++----- 2 files changed, 44 insertions(+), 7 deletions(-) diff --git a/nvim/lazy-lock.json b/nvim/lazy-lock.json index 5d6d9f8..e5bc8c0 100644 --- a/nvim/lazy-lock.json +++ b/nvim/lazy-lock.json @@ -21,7 +21,7 @@ "nvim-dap-go": { "branch": "main", "commit": "8763ced35b19c8dc526e04a70ab07c34e11ad064" }, "nvim-dap-python": { "branch": "master", "commit": "34282820bb713b9a5fdb120ae8dd85c2b3f49b51" }, "nvim-dap-repl-highlights": { "branch": "master", "commit": "a7512fc0a0de0c0be8d58983939856dda6f72451" }, - "nvim-dap-view": { "branch": "main", "commit": "98cad74ffb527bfbb085f35b786b7402cabd9924" }, + "nvim-dap-ui": { "branch": "master", "commit": "bc81f8d3440aede116f821114547a476b082b319" }, "nvim-dap-virtual-text": { "branch": "master", "commit": "df66808cd78b5a97576bbaeee95ed5ca385a9750" }, "nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" }, "nvim-surround": { "branch": "main", "commit": "caf6f633d4d77a29b6e265b560c5a035d171a913" }, diff --git a/nvim/lua/plugs/nvim-dap.lua b/nvim/lua/plugs/nvim-dap.lua index 3d56742..85e5623 100644 --- a/nvim/lua/plugs/nvim-dap.lua +++ b/nvim/lua/plugs/nvim-dap.lua @@ -5,7 +5,30 @@ local is_debug_mode_active = false return { "mfussenegger/nvim-dap", dependencies = { - { "igorlfs/nvim-dap-view", opts = {} }, + { + "rcarriga/nvim-dap-ui", + opts = { + controls = { + enabled = false, + }, + layouts = { + { + elements = { + { + id = "watches", + size = 0.5 + }, + { + id = "stacks", + size = 0.5 + } + }, + position = "bottom", + size = 15 + } + }, + } + }, -- Special adapters { "leoluz/nvim-dap-go", opts = {} }, { "mfussenegger/nvim-dap-python", }, @@ -27,8 +50,22 @@ return { { "m", function() dap.step_out() end }, { "n", function() dap.step_over() end }, { "i", function() dap.step_into() end }, - } + { + "dc", + function() + local columns = vim.o.columns + local lines = vim.o.lines + require("dapui").float_element("console", { + enter = true, + border = "rounded", + position = "center", + width = math.floor(columns * 0.8), + height = math.floor(lines * 0.6), + }) + end + }, + } local dap_signs = { { "DapBreakpoint", { text = "🛑", texthl = "", linehl = "", numhl = "" } }, { "DapBreakpointRejected", { text = "🔵", texthl = "", linehl = "", numhl = "" } }, @@ -48,7 +85,7 @@ return { is_debug_mode_active = true inlay_hints_handler.disable() - require("dap-view").open() + require("dapui").open() end local function exit_debug_mode() @@ -62,21 +99,21 @@ return { inlay_hints_handler.restore() virtual_text.clear_virtual_text() - require("dap-view").close() + require("dapui").close() end for _, request in ipairs({ { "attach", enter_debug_mode }, { "launch", enter_debug_mode }, }) do - dap.listeners.before[request[1]]["dapview"] = request[2] + dap.listeners.before[request[1]]["dapui_config"] = request[2] end for _, event in ipairs({ { "event_terminated", exit_debug_mode }, { "event_exited", exit_debug_mode }, }) do - dap.listeners.after[event[1]]["dapview"] = event[2] + dap.listeners.after[event[1]]["dapui_config"] = event[2] end local function dap_stop()