-
-
Notifications
You must be signed in to change notification settings - Fork 205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Jump to next/previous breakpoint #792
Comments
|
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as off-topic.
This comment was marked as off-topic.
I made a small function that directly uses the breakpoint data to go to the next breakpoint, without the quickfix list as intermediary. If you are at a breakpoint, it goes to the next breakpoint, otherwise, it goes to the first breakpoint. You can bind it to something like ---@param dir "next"|"prev"
local function gotoBreakpoint(dir)
local breakpoints = require("dap.breakpoints").get()
if #breakpoints == 0 then
vim.notify("No breakpoints set", vim.log.levels.WARN)
return
end
local points = {}
for bufnr, buffer in pairs(breakpoints) do
for _, point in ipairs(buffer) do
table.insert(points, { bufnr = bufnr, line = point.line })
end
end
local current = {
bufnr = vim.api.nvim_get_current_buf(),
line = vim.api.nvim_win_get_cursor(0)[1],
}
local nextPoint
for i = 1, #points do
local isAtBreakpointI = points[i].bufnr == current.bufnr and points[i].line == current.line
if isAtBreakpointI then
local nextIdx = dir == "next" and i + 1 or i - 1
if nextIdx > #points then nextIdx = 1 end
if nextIdx == 0 then nextIdx = #points end
nextPoint = points[nextIdx]
break
end
end
if not nextPoint then nextPoint = points[1] end
vim.cmd(("buffer +%s %s"):format(nextPoint.line, nextPoint.bufnr))
end If @mfussenegger is open to it, I can make a PR for this. |
I won't be adding anything in that direction until the other breakpoint variants are implemented (data, function, etc.) because it will likely influence the API, and I don't want to deal with BWC hassle in that regard. the |
Problem Statement
Often I want to move or disable a breakpoint. It would be great to have a function I could map as a motion to to jump straight to that breakpoint.
Possible Solutions
Map to something (like
]b
) so that I can immediately jump to where my next breakpoint is. From there I can disable it and move it one line down, for example, or modify the line that I am inspecting.Considered Alternatives
Could parse it out of breakpoints list myself, but I think this would be generally useful and I think it fits with a vim philosophy
The text was updated successfully, but these errors were encountered: