Closed cnrrobertson closed 1 year ago
Hey @cnrrobertson!
Glad you like my plugin! By looking at the snippet you provide, you are looking at every python binary found in $HOME, right? This would give me a list of at least 20 different python venvs to choose from. py_lsp
tries to find venvs based on a strategy like poetry
or venv
. So we should add a new conda
strategy to it.
So what we would need is a command like conda venvs list
, that lists all available venvs that are created through conda
. Do you know if there exists such a option with conda? Otherwise I could take a look at it?
Here you can find all existing strategies :)
Greetings Patrick
Yeah, so the local commands = {'fd --glob -tl python $HOME/mambaforge', 'which -a python', is_home_dir() and '' or 'find . -name python'}
is the main search command.
It finds python binaries in my conda directory ($HOME/mambaforge
), in whatever is currently activated (which -a python
could find a venv, conda environment, or just the system binary), and then if we are NOT in $HOME
it looks recursively in the current directory to find any environments. Not particularly efficient, I like your implementation better I think.
Conda does have a command conda env list
to see all available venvs. The key difference is that all the environments are stored in a $HOME
directory rather than in the project directory. It actually makes them easy to find. Common home directory names are ~/anaconda
, ~/condaforge
, ~/miniconda3
, ~/mambaforge
. But they could be named anything, so it might require an additional configuration option to get the directory..
I could write up a strategy for finding conda environments with a new source strategy conda
that looks for common names in the home directory and submit a PRif that's helpful? I could also add a new configuration option to explicitly give the conda directory name if you're up for that.
Ah, haven't noticed the mambaforge
directory.
Feel free to write a PR, if you are having any questions just write me!
Thanks in advance! 🚀
I noticed this is already on your todos, but it would be a really nice feature to see. It seems like you could integrate it pretty easily by searching the
envs
path at the conda installation location (usually something like~/conda
). I was able to follow the example here to create my own little change Python interpreter code:This provides a
PythonInterpreter
vim command which offers completion options of all conda environments and works well for me. However, I like what you are doing with this plugin much better.