linux-cultist / venv-selector.nvim

Allows selection of python virtual environment from within neovim
MIT License
378 stars 40 forks source link

Add support of virtual environments created by 'uv' #105

Closed diachkow closed 2 months ago

diachkow commented 3 months ago

Recently, a new dependency management tool called uv has been released. This tool is also capable of creating a virtual environment using the following command uv venv .venv.

However, as I discovered, venv-selector does not work correctly inside the virtual environment managed by uv, because the pyright LSP which I use for neovim was not able to locate my packages. After recreating my virtual environment using the command python3 -m venv .venv, everything worked as expected. Then I tried again to set up my virtual environment with uv and it failed again. Also, since uv is not on the list of supported venv managers for this plugin, I assume that this is the venv-selector.nvim related issue.

linux-cultist commented 2 months ago

This actually works fine for me. Uv doesnt do anything special except it names the venvs .venv.

I created a new folder at ~/uvtest, went inside it and ran uv venv to install the venv. It gets created as .venv in the folder.

Then I installed some dependencies into the uv environment:

uv pip install boto3, uv pip install snowflake and some other stuff to test it out with a project I have.

I configured VenvSelect to look in the folder i created just for the test:

    require("venv-selector").setup({
        path = "/home/cado/uvtest",
        name = ".venv",
        parents = 0
      })

And it showed up fine, and activated using VenvSelector just like any other venv.

Im currently using VenvSelector with NvChad and LazyVim and they seem to work fine, so try one of those and see if they work for you. If they do, it may be your nvim config being the issue somehow. LSP is always tricky to get right.

You should be able to get these venvs to show up by simply having them in your specified path, since they work the same as the venvs created with python3 -m venv venv.

diachkow commented 2 months ago

uv is just shipping upgrades too fast. I upgraded my local version (it's version 0.1.35 now) and checked to see if everything is working fine now, and it turns out that the problem is gone and venv-selector is working as expected with that dependency manager.

I think the issue can be closed now, thanks for double checking and informing me.

linux-cultist commented 2 months ago

Thanks!