mfussenegger / nvim-dap

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

way to abort `program` callback #1036

Closed duarm closed 8 months ago

duarm commented 10 months ago

Problem Statement

Not sure if this is a dap-ui or dap problem, I have this in my configuration

...
program = function()
    return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
end,
...

the problem is that if I start the debugger, I get prompted by the vim.fn.input function, if I change my mind, there's no way out, trying to close the input via esc still launches the ui, even when nil or false is returned by program, resulting in everything being broken, is there a workaround for that? I want to abort dap completely by returning something like nil or false.

Possible Solutions

  1. Abort dap when program returns nil or false
mfussenegger commented 8 months ago

Using nil would be tricky and a breaking change, since it can be used to unset a property. false can be a regular value, so it's also not suited.

I instead added a dap.ABORT constant that can be used for this. See https://github.com/mfussenegger/nvim-dap/pull/1079