diff --git a/README.md b/README.md index 9239e2d..3164522 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/lua/dap-python.lua b/lua/dap-python.lua index 06a2be7..2140763 100644 --- a/lua/dap-python.lua +++ b/lua/dap-python.lua @@ -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) @@ -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",