Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ To install the python tree-sitter parser you can either:
-- must work in the shell
```

Newer versions of `debugpy` also include a `debugpy-adapter` executable
which you can use in place of the `python` executable.


If using [uv][uv]:

```lua
Expand Down
17 changes: 14 additions & 3 deletions lua/dap-python.lua
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ end

--- Register the python debug adapter
---
---@param python_path "python"|"python3"|"uv"|string|nil Path to python interpreter. Must be in $PATH or an absolute path and needs to have the debugpy package installed. Defaults to `python3`.
---@param python_path "python"|"python3"|"uv"|"debugpy-adapter"|string|nil Path to python interpreter. Must be in $PATH or an absolute path and needs to have the debugpy package installed. Defaults to `python3`.
--- If `uv` then debugpy is launched via `uv run`
---@param opts? dap-python.setup.opts See |dap-python.setup.opts|
function M.setup(python_path, opts)
Expand Down Expand Up @@ -236,16 +236,27 @@ function M.setup(python_path, opts)
else
---@type dap.ExecutableAdapter
local adapter
if python_path == "uv" then
local basename = vim.fn.fnamemodify(python_path, ":t")
if basename == "uv" then
adapter = {
type = "executable",
command = "uv",
command = python_path,
args = {"run", "--with", "debugpy", "python", "-m", "debugpy.adapter"},
enrich_config = enrich_config,
options = {
source_filetype = "python"
}
}
elseif basename == "debugpy-adapter" then
adapter = {
type = "executable",
command = python_path,
args = {},
enrich_config = enrich_config,
options = {
source_filetype = "python"
}
}
else
adapter = {
type = "executable",
Expand Down
Loading