Add option to disable automatic loading of .vscode/launch.json configurations
## Summary
Currently, nvim-dap always includes configurations from `.vscode/launch.json` via the built-in `"dap.launch.json"` config provider. Some users may want to disable this behavior conditionally.
## Use cases
- Working on projects where the launch.json is intended for VS Code only
- launch.json contains configurations that conflict with nvim-dap setup
- Users who want full control over which configurations are available
- Loading launch.json only for specific projects
## Current behavior
The `"dap.launch.json"` provider is registered in `lua/dap.lua:316-324` and is always called when selecting configurations (via `dap.continue()` or similar).
Users can currently disable this by setting the provider to nil:
```lua
require('dap').providers.configs["dap.launch.json"] = nil
```
However, this is not documented, feels like an implementation detail rather than a supported API, and doesn't allow for conditional logic.
## Proposed solution
Add a setup option that accepts a function, receiving the cwd so users can implement custom logic:
```lua
require('dap').setup({
-- Function receives cwd, returns true to load launch.json, false to skip
load_launchjs = function(cwd)
-- Example: only load for specific projects
return vim.fn.filereadable(cwd .. '/.nvim-dap') == 1
end,
})
```
This allows users to:
- Disable entirely: `load_launchjs = function() return false end`
- Enable only for certain projects based on cwd
- Check for marker files, git remotes, etc.
For backwards compatibility, the default would be `load_launchjs = function() return true end`.
## Alternatives considered
Users could theoretically delete or rename their `.vscode/launch.json`, but this isn't practical when the file is needed for other editors or team members.
1 条评论