Update python.lua

This commit is contained in:
DarthMooMancer
2025-03-14 09:43:53 -04:00
parent ba33432491
commit 11b4dba228
+13 -1
View File
@@ -30,7 +30,19 @@ function M.setup(opts)
if command == "PythonRun" then M.c_run = key end
if command == "NewPythonFile" then M.new_python_file = key end
end
vim.fn.system("source ./venv/bin/activate")
local root = M.get_project_root()
if root then
local venv_path = root .. "/venv/bin/activate"
if vim.fn.filereadable(venv_path) == 1 then
-- Activate the virtual environment
vim.env.VIRTUAL_ENV = venv_path
vim.env.PATH = root .. "/venv/bin:" .. vim.env.PATH
print("Virtual environment activated.")
else
print("No virtual environment found.")
end
end
vim.api.nvim_create_user_command("NewPythonFile", M.create_new_file, {})
vim.api.nvim_create_user_command("PythonRun", M.run, {})