Closed UtkarshKunwar closed 1 year ago
Hi and sorry for late response, I was on vacation in Italy and just came back :)
I think you may want to add "parents = 0" to your options there if you want VenvSelect to not go up into parent directories and look for venvs. Maybe that should be default - I can see how its confusing that its looking in parent directories when you specify a specific path to search. This should probably be changed so if the user sets a path, parents are also set to 0 by default. :)
But even if you do that, the virtual environments will have different names under the path (the name you give your virtual environment), and wont be found. So I think adding direct support for virtualenvwrapper
to VenvSelector is probably a good idea.
Then it will find those environments without any config on your part. I will see what I can do. :)
If you update VenvSelector now to latest version, it should find virtual environments under ~/.virtualenvs
and list them.
But you need to change your config so its more like default:
require("venv-selector").setup({
search_venv_managers = true,
auto_refresh = true,
search = false
})
With this config, the search_venv_managers
option is true, and it needs to be so VenvSelector can find the managed venvs. Its default set to true so you can also remove that option from your config.
You also dont need path
and the name
options for your use case. They are used to search for virtual environments that are not managed by a venv manager such as virtualenvwrapper
.
The search
parameter set to false will make VenvSelector not search at all for venvs that are not managed by a venv manager, which will make the plugin a lot faster for you. But remember to set it to true if you actually want to look for venv folders outside of virtualenvwrapper
.
Hope all this works for you!
Closing this, but feel free to comment or reopen if the new code doesn't work for some reason. :)
I'm sorry for not getting back to you sooner, but it seems to work now with your provided configuration.
Another follow-up question is that if I change the virtual environment using this plugin, how do I have it enforce the same on the already open terminal(s)? I am using ToggleTerm but I think that the logic of this post-activate hook would apply to the standard terminal as well. Do you think I should file a separate issue so that the discussion is contained?
I have been trying to configure the plugin using the following configuration,
I am using
virtualenvwrapper
so commands likeworkon VENV
anddeactivate
are supported via the command line. But with this configuration it is not able to find my venvs located under the specificied path. Instead it also searches through all the venvs in other user's home directories which I found was unexpected.I could only find documentation for the other venv managers like
pyenv-virtualenv
which I migrated away from as it didn't let me runpython
withgdb
because of shims. If you could guide me on how to configure thisvirtualenvwrapper
that would be great!