Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This commit introduces a
cwd
option todap-python.setup.opts
, enabling users to specify the working directory for debug sessions.nil
to preserve existing behavior.Current Configuration
Here is my current
nvim-dap-python
setup:Issue Faced
Given the following project structure:
When I open Neovim in the project folder, load
examples/generate_signature.py
, and run the debugger usingrequire("dap").continue()
, I encounter the following error:This happens because
debugpy
defaults the working directory (cwd
) to the directory containing the file being debugged (./examples
) rather than the Neovim working directory (vim.fn.getcwd()
). As a result, relative paths likekeys/private_key.pem
are resolved incorrectly.Proposed Solution
To resolve this issue, I propose adding an optional
cwd
parameter to thedap-python.setup.opts
configuration. This option will allow users to explicitly specify the working directory for debugging sessions. By default,debugpy
uses the directory of the file being debugged as the working directory, but with this change, users can customize thecwd
to match Neovim’s current working directory (vim.fn.getcwd()
), ensuring that relative paths are resolved correctly.Changes:
cwd
option to thedap-python.setup.opts
configuration.cwd
option can be set to a function that dynamically returns the desired directory. If the option is not set, the default behavior (using the file's directory) will be maintained.Updated
nvim-dap-python
configuration: