mfussenegger / nvim-dap

Debug Adapter Protocol client implementation for Neovim
GNU General Public License v3.0
5.56k stars 199 forks source link

Add UI and API for ease of control over breakpoints #448

Open przepompownia opened 2 years ago

przepompownia commented 2 years ago

Problem Statement

Currently the have two ways to centralized control all breakpoints: by running dap.clear_breakpoints() or dap.list_breakpoints(). The later allows for overview and jumping to the selected breakpoint.

Sometimes I would like to, for example, remove all except two breakpoints. It would be good to can remove some subset created by some selection or some API call (to utilize on dap-ui-like interfaces).

Ideas or possible solutions

From the UI point of view: mapping dd (or anything configurable) on a single quickfix item to remove breakpoint would be a significant step ahead.

mfussenegger commented 2 years ago

From the UI point of view: mapping dd (or anything configurable) on a single quickfix item to remove breakpoint would be a significant step ahead.

I'd kinda like that, but afaik it's currently not possible to have quickfix context specific mappings. It would probably need a dedicated widget and I currently don't plan to add that, unless adding support for data breakpoints or dependant breakpoints will make it necessary.

This might be something that fits more into https://github.com/rcarriga/nvim-dap-ui than the nvim-dap core.

przepompownia commented 1 year ago

While browsing nvim-dap sources to try to make use of https://github.com/theHamsta/nvim-dap-virtual-text/pull/50 I found what toggle_breakpoint does in details. It seems that

require'dap.breakpoints'.remove(vim.api.nvim_buf_get_number(0), 22)
require 'dap'.session():set_breakpoints(require'dap.breakpoints'.get(vim.api.nvim_buf_get_number(0)))

is enough to remove breakpoint from the current buffer on line 22.

If it's correct, what do you think about adding explicit method to remove breakpoint by filename/bufnr and line?

hebaishi commented 7 months ago

Just wanted to pitch in - I would love to extend the existing set_breakpoint API to take a custom filename and line number. This would be extremely useful in C++ projects if you want to set a breakpoint in external code. Perhaps we could combine setting and removing breakpoints by filename string? Note that I don't think adding UI elements belongs in this project - I would only like to make the API a bit more flexible.

@mfussenegger Thoughts?