diff --git a/lua/dap-python.lua b/lua/dap-python.lua index c87510a..a504652 100644 --- a/lua/dap-python.lua +++ b/lua/dap-python.lua @@ -27,6 +27,17 @@ local function default_runner() return 'pytest' elseif uv.fs_stat('manage.py') then return 'django' + elseif uv.fs_stat("pyproject.toml") then + local f = io.open("pyproject.toml") + if f then + for line in f:lines() do + if line:find("%[tool.pytest") then + f:close() + return "pytest" + end + end + f:close() + end else return 'unittest' end @@ -146,17 +157,11 @@ end ---@return string[] local function flatten(...) - local argc = select("#", ...) - local result = {} - for i = 1, argc do - local arg = select(i, ...) - if type(arg) == "table" then - vim.list_extend(result, arg) - else - table.insert(result, arg) - end + local values = {...} + if vim.iter then + return vim.iter(values):flatten(2):totable() end - return result + return vim.tbl_flatten(values) end