Question [ How configure the plugin with venvs ]
When developing in python, is normal that different projects have different env. We can use, venv, poetry, etc.
How we indicate to the plugin which venv we want to use?
I'm not sure how pylsp identifies that. Are there any resources you know of that explain how that would be done?
I think the question is: how to make this plugin talk with a particular pylsp installed in a specific environment (generally tied to the project).
I think the question is: how to make this plugin talk with a particular
pylspinstalled in a specific environment (generally tied to the project).
Yes, that is exactly my point.
Lapce "talks" with the language server, rather than the plugin direclty. The plugin can specify arguments passed to the language server when it is started. Outside that, we'd have to look into the language server protocol and the subset that Lapce supports.
One option might be to read the configuration (e.g., the executable in the venv) in the pyproject.toml. That's now the default place where tool config is supposed to go
- activate your venv in a terminal
- start lapce in the same terminal
activate your venv in a terminal
- start lapce in the same terminal
Thanks a ton. This is what I was looking for
activate your venv in a terminal
start lapce in the same terminal
Do we think this is the proper way to do it and should be added to the README? Or do other language plugins handle this more intelligently?
- activate your venv in a terminal
- start lapce in the same terminal
Do we think this is the proper way to do it and should be added to the README? Or do other language plugins handle this more intelligently?
pylsp (via jedi) provides a config option just for that purpose: pylsp.plugins.jedi.environment (https://github.com/python-lsp/python-lsp-server/issues/496). I think the cleanest way to implement this is to read the pylsp config from the current dir (./.pylsp-config, or something like that, with fallbacks if necessary) and configure pylsp on startup of the server. Ideally pyproject.toml should be an accepted source for this config. To make things as simple as possible, the config options should be passed verbatim to pylsp.
This may already be possible, I don't know. I've tried a couple of things with no success, so I'm assuming not, but it's possible I missed something obvious. If there's documentation for doing this, I couldn't find it.