feat(LSP): Modify the way a virtual env is located

Changed the hard-coded virtual environment directory name used to look
for Python related binaries to whatever directory is defined in the
`VIRTUAL_ENV` environment variable.  That variable's value is more
reliable, even more when Python virtual environments are located in a
central location, not near the repository.
This commit is contained in:
Dionisio E Alonso 2024-03-02 17:29:42 -03:00
parent 8d626d2188
commit b15b9178c6
1 changed files with 2 additions and 2 deletions

View File

@ -35,8 +35,8 @@ local pylsp_settings = {
},
}
local venv_dir = vim.fn.finddir(".venv/", vim.fn.expand("%:p:h") .. ";")
if venv_dir ~= "" then
local venv_dir = vim.env.VIRTUAL_ENV
if venv_dir ~= nil then
local python_exec = vim.fn.findfile("python", venv_dir .. "/bin;")
if python_exec ~= "" then
pylsp_settings.plugins.jedi = {environment = python_exec}