diff --git a/lua/turbo-debug/config.lua b/lua/turbo-debug/config.lua index 492fa4b..66c712d 100644 --- a/lua/turbo-debug/config.lua +++ b/lua/turbo-debug/config.lua @@ -62,6 +62,12 @@ M.defaults = { -- sidebar position: "left" (default) or "right" sidebar = "left", + -- Optional colorscheme to switch to while debug mode is active. + -- `nil` (default) keeps the user's current colorscheme. Any other + -- string value is passed directly to `:colorscheme`. On M.exit the + -- previous colorscheme is restored. + colorscheme = nil, + -- highlight the active dapui pane's border/separator vs. dim inactive panes active_window_highlight = true, diff --git a/lua/turbo-debug/mode.lua b/lua/turbo-debug/mode.lua index 0a04f55..84dbb2f 100644 --- a/lua/turbo-debug/mode.lua +++ b/lua/turbo-debug/mode.lua @@ -43,6 +43,13 @@ local last_dapui_total_height = nil -- color. Restored byte-for-byte on M.exit. local saved_winsep_hl = nil +-- The user's colorscheme at M.enter time, saved only if `config.opts. +-- colorscheme` is set and the current colorscheme differs. Restored on +-- M.exit. Lets the user pin a distinct theme for debug sessions (e.g. a +-- high-contrast theme for reading register dumps) without permanently +-- switching their editor. +local saved_colorscheme = nil + local dapui_initialized = false local vt_initialized = false @@ -306,29 +313,53 @@ local function action(name) return function() local a = M.actions(); if a[name] then a[name]() end end end +-- Returns the user's configured key for an action, or the fallback default +-- when the user hasn't overridden it. Returns nil when the action is +-- explicitly disabled (set to `false` in config.opts.keys) — callers should +-- SKIP rendering a legend entry for that action entirely, since the modal +-- keymap install path at M._install_for_buf also skips it. local function keyof(name, fallback) local k = config.opts.keys[name] - if type(k) == "string" then return k end + if k == false then return nil end + if type(k) == "string" and k ~= "" then return k end return fallback end --- Build a label's byte-level representation. --- Format: " ()[ ]" --- e.g. ` (s)tep over` with `over` styled italic. +-- Build a control label's byte-level representation. +-- +-- Picks between two forms based on whether the user's actual key matches +-- the first letter of the label (case-insensitive): +-- inline: " ()[ ]" e.g. "(s)tep over" +-- prefix: " ()