Open vakker opened 4 years ago
I think so. So pyls resolves the environment based on jedi?
Well the issue is that we should not need to install the pyls plus all the required deps on a given environment. pyls should (in theory) just live on the main environment. Jedi provides such facilities so that most of the things can be done by setting that option to point to the right env (python executable).
Now @andfoy might want to chime in with more information.
Otherwise you need to install pyls on that environment an use
"pyls.executable": {
"type": "string",
"default": "pyls",
"description": "Language server executable"
},
I see what you mean.
Okey, I managed to activate the environment in Emacs and restart pyls and then it picks up the right environment. However, as you said, this requires pyls to be installed in the target environment which is not ideal.
If I just set the pyls.plugins.jedi.environment
, and use pyls from the base env then jedi works as expected, but I'm still getting pylint issues as it seems to run in the base env.
Looking into your pylint_lint.py
setting the env based on jed.environment seems to be missing (if I'm not mistaken). For the record, pylint doesn't provide an easy way to do this, e.g. see this and there's also this project (for venv, but I assume the same logic applies for conda).
If I just set the pyls.plugins.jedi.environment, and use pyls from the base env then jedi works as expected
Great! That's what @goanpeca was talking about.
but I'm still getting pylint issues as it seems to run in the base env.
That's a separate issue, but since you verified that completion is working for different envs, I'll change the title of this issue to reflect that Pylint is not working for this use case.
there's also this project (for venv, but I assume the same logic applies for conda).
I took a look at that project and it seems pretty simple: we just need to extend the sys.path
of the Pylint process to include the one provided by the env.
If you want to tackle this one, we'd be really grateful. Else, you'll have to wait us a couple of months for a fix.
For the record, it's not just pylint, but everything else than jedi I think. Probably it doesn't make any difference for yapf, isort, etc. , but mypy, flake, and alike would benefit from setting the environment according to the project.
For now I'll just go with installing pyls in the project environment as I already got that working and I'm a bit swamped currently so I can't work on this at the moment. But if you need any input on this just let me know.
How do you set the conda environment for pyls? I'm using emacs and pyls only uses the base environment. I tried using conda-mode for changing the environment, but pyls still uses the base.