From 90161be418c1c8da3aa359cb185a40685ba118ed Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Mon, 3 Feb 2025 16:37:55 +0100 Subject: [PATCH] nvim: Add check for local .venv python dir --- nvim/.config/nvim/lua/core/util.lua | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/nvim/.config/nvim/lua/core/util.lua b/nvim/.config/nvim/lua/core/util.lua index 043136a..5fb9e4a 100644 --- a/nvim/.config/nvim/lua/core/util.lua +++ b/nvim/.config/nvim/lua/core/util.lua @@ -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