nvim: Add check for local .venv python dir

This commit is contained in:
Marty Oehme 2025-02-03 16:37:55 +01:00
parent 8b5e4dc097
commit 90161be418
Signed by: Marty
GPG key ID: EDBF2ED917B2EF6A

View file

@ -64,6 +64,11 @@ function T.get_python_venv_basefolder(workspace)
return venv_path_cached
end
local match
match = vim.fn.finddir(".venv", "**1")
if match ~= "" then
venv_path_cached = match
return venv_path_cached
end
-- Look downwards for file, can be nested. Limit to 1 depth for speed rn
-- TODO: Maybe not hardcode 1-depth but allow choice.
match = vim.fn.findfile("pyvenv.cfg", "**1")
@ -79,8 +84,8 @@ function T.get_python_venv_basefolder(workspace)
if obj.code ~= 0 then
return
end
local venv_base_folder = obj.stdout:match("^%s*(.-)%s*$")
venv_path_cached = venv_base_folder
match = obj.stdout:match("^%s*(.-)%s*$")
venv_path_cached = match
return venv_path_cached
end
end