Config entries like language.<language-identifier>.languageServer.env specify a group of additional environment variables for each language server when spawning its process.
pyls detects the env VIRTUAL_ENV to set up the completion scope/virtualenv. This is a crucial setting when pyls is installed in a different virtualenv to the project. I can start pyls by setting language.python.languageServer.command="/path/to/pyls_virtualenv/bin/pyls", but without setting VIRTUAL_ENV, the server by default supply completion in scope /path/to/pyls_virtualenv, not the one my project located.
Thanks for the detailed issue, @Contextualist ! Having an option to override / pass down additional environment variables to the language server makes sense.
It's possible to work around this using the env command:
{
"language.python.languageServer.command": "/usr/bin/env",
"language.python.languageServer.arguments": [
"VIRTUAL_ENV=/Users/alex/.local/share/virtualenvs/backend-kydAUAQj", // <-- path here
"/usr/local/bin/pyls"
]
}
Most helpful comment
It's possible to work around this using the
envcommand: