mfussenegger / nvim-dap

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

rfc: configuration providers #1226

Closed mfussenegger closed 1 month ago

mfussenegger commented 1 month ago

Problem Statement

Currently you always need to be in a file with the right filetype to start a debug session.

This works well enough for many work patterns, but on some type of projects it's common that you're in another buffer. E.g. you might want to start django while editing a HTML file. Or you're in the REPL and want to start a debug session again.

Possible Solutions

Showing all global configuration options is probably too much, but a compromise could be to:

  1. Show all local configurations (from .vscode/launch.json)
  2. Show global configurations related to the filetype as is.
  3. Provide a provider.configs extension points for additional sources. (E.g. some language servers/plugins provide functionality to discover entry points)

Always doing 1) could also remove the need to specify a filetype/debug-adapter-type mapping as part of the load_launchjs call.

1) and 2) would be implemented using the provider/configurations extension points, that means people could also unregister or replace them.

For 3) I'm thinking of something like:

local dap = require("dap")
dap.provider.configs[plugin_name] = function()
    -- can return a list of configurations, or a thread that will yield the list
end

(I'm also thinking of other types of providers, like variable formatting or yank-as-<format> functionality - hence the provider namespace. Or dap.ext.?)

I'd like to get some feedback on this.

Considered Alternatives

No response

mfussenegger commented 1 month ago

Implemented with https://github.com/mfussenegger/nvim-dap/pull/1237