lapce-python icon indicating copy to clipboard operation
lapce-python copied to clipboard

Question [ How configure the plugin with venvs ]

Open nstirnemann7 opened this issue 3 years ago • 9 comments

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?

nstirnemann7 avatar Dec 05 '22 04:12 nstirnemann7

I'm not sure how pylsp identifies that. Are there any resources you know of that explain how that would be done?

superlou avatar Dec 17 '22 01:12 superlou

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).

IGJAmpere avatar Dec 20 '22 08:12 IGJAmpere

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).

Yes, that is exactly my point.

BatmiBoom avatar Dec 20 '22 14:12 BatmiBoom

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.

superlou avatar Dec 20 '22 15:12 superlou

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

StefanUlbrich avatar Jan 29 '23 15:01 StefanUlbrich

  1. activate your venv in a terminal
  2. start lapce in the same terminal

wwhio avatar Apr 17 '23 03:04 wwhio

  1. activate your venv in a terminal

    1. start lapce in the same terminal

Thanks a ton. This is what I was looking for

mildlyautistic avatar Dec 05 '23 13:12 mildlyautistic

  1. activate your venv in a terminal

  2. 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?

superlou avatar Dec 05 '23 13:12 superlou

  1. activate your venv in a terminal
  2. 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.

thomas-mckay avatar Jul 08 '24 15:07 thomas-mckay