fix python debugging

This commit is contained in:
Mathias Schneider
2026-05-28 17:02:00 +02:00
parent 07635d8226
commit 5be8fcf43f
+9 -17
View File
@@ -5,6 +5,7 @@ return {
dependencies = "mfussenegger/nvim-dap",
config = function()
local dap = require("dap")
require("dap-python").setup()
dap.configurations.python = {
@@ -13,55 +14,46 @@ return {
request = "launch",
name = "Launch file",
program = "${file}",
pythonPath = function()
return vim.fn.exepath("python3") or "python"
end,
cwd = "${workspaceFolder}",
env = { PYTHONPATH = "${workspaceFolder}" },
},
{
type = "python",
request = "launch",
name = "Debug current file (integrated terminal)",
program = "${file}",
cwd = "${workspaceFolder}",
console = "integratedTerminal",
pythonPath = function()
return vim.fn.exepath("python3") or "python"
end,
env = { PYTHONPATH = "${workspaceFolder}" },
},
{
type = "python",
request = "launch",
name = "Debug with arguments",
program = "${file}",
cwd = "${workspaceFolder}",
args = function()
local args = vim.fn.input("Args: ", ""):split(" ")
return args
end,
console = "integratedTerminal",
pythonPath = function()
return vim.fn.exepath("python3") or "python"
end,
env = { PYTHONPATH = "${workspaceFolder}" },
},
{
type = "python",
request = "launch",
name = "Debug test_api.py",
module = "unittest",
args = { "test.test_api", "-v" },
cwd = "${workspaceFolder}",
pythonPath = function()
return vim.fn.exepath("python3") or "python"
end,
args = { "test.test_api", "-v" },
},
{
type = "python",
request = "launch",
name = "Debug all tests",
module = "unittest",
args = { "discover", "-s", "test", "-v" },
cwd = "${workspaceFolder}",
pythonPath = function()
return vim.fn.exepath("python3") or "python"
end,
args = { "discover", "-s", "test", "-v" },
},
}
end,