Update python.lua
This commit is contained in:
+13
-1
@@ -30,7 +30,19 @@ function M.setup(opts)
|
|||||||
if command == "PythonRun" then M.c_run = key end
|
if command == "PythonRun" then M.c_run = key end
|
||||||
if command == "NewPythonFile" then M.new_python_file = key end
|
if command == "NewPythonFile" then M.new_python_file = key end
|
||||||
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("NewPythonFile", M.create_new_file, {})
|
||||||
vim.api.nvim_create_user_command("PythonRun", M.run, {})
|
vim.api.nvim_create_user_command("PythonRun", M.run, {})
|
||||||
|
|||||||
Reference in New Issue
Block a user