1

I want LSP to allow me to use pyright with peotry projects. The problem is, that the venv of a poetry project is kind of arbitrary and can change. So I can not configure it in the pyright config file.

Can LSP be configured to "autodetect" this environment and set it for pyright when I open a project?

1
  • "Autodetect"? I can't even configure pyright to use venv manually.
    – 3N4N
    Oct 11, 2022 at 5:58

1 Answer 1

0

Pyright correctly recognizes python on your PATH. So if you activate a virtual environment in a shell and open neovim there, everything should work as expected.

Run the following command in neovim

!which python

or

echo $PATH

to see whether the virtualenv python is detected in neovim.

2
  • !which python has nothing to do with neovim, though. It's a shell command.
    – 3N4N
    Nov 2, 2022 at 7:07
  • Yes, it is a shell command but the $PATH environment variable will be propagated to the subshell command executed in neovim. So it can tell which python will be picked by pyright (it chooses one as per $PATH) -- unless you configured pyright to use a different python interpreter. Nov 7, 2022 at 22:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.