From 8702bcb312c371d020cc678a1fb086f578282795 Mon Sep 17 00:00:00 2001 From: Stephen Waits Date: Sat, 11 Apr 2026 19:30:41 -0600 Subject: [PATCH] feat: debug mode winbar chrome, dapui panel titles, bigger stopped arrow --- lua/tiny-debugger/breakpoints.lua | 2 +- lua/tiny-debugger/mode.lua | 58 +++++++++++++++++++++++++------ 2 files changed, 49 insertions(+), 11 deletions(-) diff --git a/lua/tiny-debugger/breakpoints.lua b/lua/tiny-debugger/breakpoints.lua index 7fb9174..7badb01 100644 --- a/lua/tiny-debugger/breakpoints.lua +++ b/lua/tiny-debugger/breakpoints.lua @@ -23,7 +23,7 @@ function M.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("DapStopped", { text = "▶️", texthl = "DapStopped", linehl = "DapStoppedLine" }) + vim.fn.sign_define("DapStopped", { text = "➤", texthl = "DapStopped", linehl = "DapStoppedLine" }) vim.fn.sign_define("DapLogPoint", { text = "📝", texthl = "DapLogPoint" }) -- global mappings (work outside debug mode) diff --git a/lua/tiny-debugger/mode.lua b/lua/tiny-debugger/mode.lua index 3dcdefc..c482e43 100644 --- a/lua/tiny-debugger/mode.lua +++ b/lua/tiny-debugger/mode.lua @@ -5,7 +5,9 @@ local M = {} local active = false local active_buf = nil +local active_win = nil local stashed_maps = {} +local saved_winbar = nil -- one-time dap-ui and virtual-text initialization local dapui_initialized = false @@ -23,6 +25,36 @@ local function ensure_dapui() dap.listeners.after.event_exited["tiny-debugger"] = function() if active then M.exit() end end + + -- set winbar titles on dapui panels + local titles = { + dapui_scopes = " Scopes", + dapui_watches = " Watches", + dapui_stacks = " Call Stack", + dapui_console = " Console", + dapui_breakpoints = " Breakpoints", + } + vim.api.nvim_create_autocmd("FileType", { + pattern = "dapui_*", + callback = function(args) + local title = titles[vim.bo[args.buf].filetype] + if title then + vim.schedule(function() + local win = vim.fn.bufwinid(args.buf) + if win ~= -1 then vim.wo[win].winbar = title end + end) + end + end, + }) + vim.api.nvim_create_autocmd("FileType", { + pattern = "dap-repl", + callback = function(args) + vim.schedule(function() + local win = vim.fn.bufwinid(args.buf) + if win ~= -1 then vim.wo[win].winbar = " REPL" end + end) + end, + }) end local function ensure_vt() @@ -48,7 +80,7 @@ local function restore_mapping(buf, lhs) if map then local rhs = map.rhs or map.callback if rhs then - vim.keymap.set("n", lhs, rhs, { + pcall(vim.keymap.set, "n", lhs, rhs, { buffer = buf, silent = map.silent == 1, noremap = map.noremap == 1, @@ -124,18 +156,24 @@ local function clear_keymaps(buf) stashed_maps = {} end --- cursor highlight +-- debug mode chrome -local saved_cursor_hl = nil +local function set_debug_chrome() + active_win = vim.api.nvim_get_current_win() + saved_winbar = vim.wo[active_win].winbar + vim.wo[active_win].winbar = "%#DiagnosticError# 🐛 DEBUG %* %f" -local function set_cursor_highlight() - saved_cursor_hl = vim.api.nvim_get_hl(0, { name = "Cursor" }) vim.api.nvim_set_hl(0, "Cursor", { bg = "#ff6600", fg = "#000000" }) end -local function restore_cursor_highlight() - vim.api.nvim_set_hl(0, "Cursor", saved_cursor_hl or {}) - saved_cursor_hl = nil +local function clear_debug_chrome() + if active_win and vim.api.nvim_win_is_valid(active_win) then + vim.wo[active_win].winbar = saved_winbar or "" + end + active_win = nil + saved_winbar = nil + + vim.api.nvim_set_hl(0, "Cursor", {}) end -- public API @@ -147,7 +185,7 @@ function M.enter() active_buf = vim.api.nvim_get_current_buf() set_keymaps(active_buf) - set_cursor_highlight() + set_debug_chrome() ensure_dapui() require("dapui").open() @@ -166,7 +204,7 @@ function M.exit() clear_keymaps(active_buf or vim.api.nvim_get_current_buf()) active_buf = nil - restore_cursor_highlight() + clear_debug_chrome() help.close() if dapui_initialized then require("dapui").close() end