Closed charlesneimog closed 1 year ago
Hey! A quick google search didnt really help.
How does conda
interact with the pyproject.toml
file? Could you link me some docu about the venv
property?
Ohh, I am sorry, I was not clear.
I don't mean that it interacts. For now, with the py_lsp plugin
, we need to run PyLspActivateCondaEnv
to make the LSP work correctly. For me, It would be great to add natively the possibility to read, for example, the venv
key, from the pyright and make it run PyLspActivateCondaEnv
automatically. Because I always am changing env, and always need to run PyLspActivateCondaEnv
. The JSON file pyrightconfig.json
already have one key called venv
, maybe `py_lsp' could read it and run PyLspActivateCondaEnv.
I was able to make a simple script to solve my needs. I will close the issue.
-- in the root of the project, read the key venv of pyrightconfig.json
local function GetVenvName()
local f = io.open("pyrightconfig.json", "r")
if f == nil then
return nil
end
local content = f:read("*all")
f:close()
local VenvName = string.match(content, '"venv": "(.-)"')
return VenvName
end
local function activateVenv()
local VenvName = GetVenvName()
-- from python py_lsp, use the function PyLspActivateCondaEnv
if VenvName ~= nil then
vim.cmd("PyLspActivateCondaEnv " .. VenvName)
end
end
activateVenv()
Hey,
Thanks for the work!
Would it be possible to make py_lsp read the
venv
property ofpyproject.toml
(thinking about conda envs).