breakpoints: persistent breakpoints with global x/X mapping

This commit is contained in:
swaits committed 2026-04-11 16:39:28 -06:00
1 parent 3729d333ff
commit aaac6273c0
4 files changed
+58

No files matched your search

+29
View File
@@ -0,0 +1,29 @@
local config = require("tiny-debugger.config")
local M = {}
local initialized = false
function M.setup()
if initialized then return end
initialized = true
require("persistent-breakpoints").setup({
load_breakpoints_event = { "BufReadPost" },
})
-- global mappings — these work outside debug mode
local keys = config.opts.keys
if keys.breakpoint then
vim.keymap.set("n", keys.breakpoint, function()
require("persistent-breakpoints.api").toggle_breakpoint()
end, { silent = true, desc = "tiny-debugger: toggle breakpoint" })
end
if keys.cond_breakpoint then
vim.keymap.set("n", keys.cond_breakpoint, function()
require("persistent-breakpoints.api").set_conditional_breakpoint()
end, { silent = true, desc = "tiny-debugger: conditional breakpoint" })
end
end
return M
+2
View File
@@ -1,10 +1,12 @@
local config = require("tiny-debugger.config")
local mode = require("tiny-debugger.mode")
local breakpoints = require("tiny-debugger.breakpoints")
local M = {}
function M.setup(opts)
config.merge(opts)
breakpoints.setup()
end
function M.toggle()
+3
View File
@@ -13,6 +13,9 @@ vim.pack.add({ "nvim-neotest/nvim-nio" })
vim.pack.add({ "theHamsta/nvim-dap-virtual-text" })
vim.pack.add({ "Weissle/persistent-breakpoints.nvim" })
-- initialize with defaults (user can call setup() to override)
require("tiny-debugger").setup()
-- toggle debug mode
vim.keymap.set("n", "<leader>d", function()
require("tiny-debugger").toggle()
+24
View File
@@ -0,0 +1,24 @@
-- tests for persistent breakpoints
local td = require("tiny-debugger")
td.setup()
local function assert_eq(a, b, msg)
if a ~= b then
error(string.format("FAIL: %s — expected %s, got %s", msg, vim.inspect(b), vim.inspect(a)))
end
end
-- test 1: global x mapping exists
local maparg = vim.fn.maparg("x", "n", false, true)
assert_eq(maparg.desc, "tiny-debugger: toggle breakpoint", "global x mapping exists")
-- test 2: global X mapping exists
maparg = vim.fn.maparg("X", "n", false, true)
assert_eq(maparg.desc, "tiny-debugger: conditional breakpoint", "global X mapping exists")
-- test 3: persistent-breakpoints API is callable
local api = require("persistent-breakpoints.api")
assert_eq(type(api.toggle_breakpoint), "function", "toggle_breakpoint is a function")
assert_eq(type(api.set_conditional_breakpoint), "function", "set_conditional_breakpoint is a function")
print("ALL BREAKPOINT TESTS PASSED")