Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question [ How configure the plugin with venvs ] #11

Open
nstirnemann7 opened this issue Dec 5, 2022 · 9 comments
Open

Question [ How configure the plugin with venvs ] #11

nstirnemann7 opened this issue Dec 5, 2022 · 9 comments

Comments

@nstirnemann7
Copy link

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?

@superlou
Copy link
Owner

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

@IGJAmpere
Copy link

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

@BatmiBoom
Copy link

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.

@superlou
Copy link
Owner

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.

@StefanUlbrich
Copy link

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

@wwhio
Copy link

wwhio commented Apr 17, 2023

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

@mildlyautistic
Copy link

  1. activate your venv in a terminal

    1. start lapce in the same terminal

Thanks a ton. This is what I was looking for

@superlou
Copy link
Owner

superlou commented Dec 5, 2023

  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?

@thomas-mckay
Copy link

  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 (python-lsp/python-lsp-server#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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants