Closed qizidog closed 1 year ago
Based on my observation, configuring the several path
variables mentioned above seems to have no practical effect. Perhaps users should be allowed to prohibit unnecessary search paths to avoid excessive search time consumption
Venvwrapper and Anaconda support was recently added and I havent updated the README (thanks for the reminder!).
Poetry, Pipenv and Pyenv should be mentioned in the README under their own sections where they are discussed. Also has some info how to find out the default path etc.
Changing these options to something else should have an effect and the plugin should look in those paths instead of the default paths. Can you share an example config that doesn't work, and also list the files in that directory please.
Perhaps I didn't express myself clearly enough, I mean that the search_venv_managers
option seems unclear, the content after "you can" is missing.
-- search_venv_managers (default: true). Will search for Poetry and Pipenv virtual environments in their -- default location. If you dont use the default location, you can search_venv_managers = true,
Since I only use conda, my original idea was to avoid searching other directories outside of the conda environment (I can always search for twenty to thirty venvs).
I partly achieved my goal by setting search=false
(actually by search_venv_managers
), but I still believe that the search
option is somewhat confusing and the path
option takes no effect.
All my config is as followed:
{
"linux-cultist/venv-selector.nvim",
opts = {
dap_enabled = true,
search = false,
-- parents = 0,
search_venv_managers = true,
-- path = os.getenv("CONDA_PREFIX") .. "/envs",
},
keys = { { "<leader>cv", "<cmd>:VenvSelect<cr>", desc = "Select VirtualEnv" } },
},
In my opinion, the relationship between the three options path
, search_venv_managers
, and search
needs to be reconsidered. For example, when path
is set, all other paths should not be searched.
If I set search = false
, path = os.getenv("CONDA_PREFIX") .. "/envs"
and search_venv_managers = false
, no venv would be found.
If I set
search = false
,path = os.getenv("CONDA_PREFIX") .. "/envs"
andsearch_venv_managers = false
, no venv would be found.
This is correct behavior since Conda is seen as a venv manager by the plugin.
But yes, I agree with what you are saying in this thread. The plugin originally started out as just supporting venv folders (created with python3 -m venv venv
in my project folder or in a parent folder) and with time, I added support for more things. So now the options are somewhat confusing because I didnt want to break backwards compatibility.
In my opinion, the relationship between the three options path, search_venv_managers, and search needs to be reconsidered. For example, when path is set, all other paths should not be searched.
The path
option is only supposed to be used when searching for manually created venvs (not conda, pipenv, poetry etc). Its basically how you tell VenvSelect to not go looking in project_folder
's parent directories for manually created venvs, and instead just use the path
you set for the projects. It will look in your path
directory but still go up to parents
directories unless you set parents
to 0.
For conda, you should set anaconda_path
to where your conda managed venvs can be found. search_venv_managers
need to be true, but search
can be false if you dont want to look for manually created venvs.
With all these options, its even more important that the README is clear and easier to understand. I will take a look at it and add examples to hopefully make it more clear. I can completely understand the frustration of not getting a plugin to work because its complicated to understand. I have been there myself many times. :)
It sounds like you should use a config like this:
{
"linux-cultist/venv-selector.nvim",
opts = {
dap_enabled = true,
search = false,
search_venv_managers = true,
anaconda_path = os.getenv("CONDA_PREFIX") .. "/envs",
},
keys = { { "<leader>cv", "<cmd>:VenvSelect<cr>", desc = "Select VirtualEnv" } },
}
I just switched out path
for anaconda_path
.
I have ideas for a new major version where most of these options simply go away, and instead is replaced by preconfigured regular expressions (and let the user write his own as well). After all, the plugin mostly does two things:
1) Search file system for files matching a pattern. 2) Show them in the telescope viewer so they can be activated.
But it will take some time to make a big change like that.
Also specifically for conda, the plugin was not designed to support Conda in the way described here: https://github.com/linux-cultist/venv-selector.nvim/issues/37
But I think its possible to support, specially with custom paths from regular expressions deciding what to match.
That's brilliant! This project has already provided me with a lot of convenience 😄
Some discription of options is not complete, just search in
README.md
Additionally, there are some options that are not mentioned in readme, such as
Suggest writing the function of the parameter into
config.lua
.