feat: Add new feature to auto create a venv directory and set
-
feat(venv): new feature auto_create_venv uses either pdm or pip to attempt to find a dependency file and create a venv directory automatically.
-
docs(post_set_venv): Add snippet for reloading an lsp client on post_set_venv
-
docs(auto_venv): Adjust auto_venv section to be about auto_create_venv
@AckslD any thoughts? Is this something you would want in swenv or does it belong in a separate plugin that just calls swenv?
Hi @joshzcold! Sorry for a late response, I have been travelling and been mostly offline from github. I haven't looked at this in detail but seems really nice. I hope to be able to get to this in not to long :)
@AckslD Does the answers to your question help or should I implement some changes?
I could a little bit more into trying to remove that global variable.
@joshzcold The answers do help. I'm sorry for being very slow again, I'm not managing to spend a lot of time here atm. I can fully understand if my responses are too slow and you loose interest in this. But my intention is still to try to review and help finish this.
Re the global variable, it's not a very big change but unless I'm misunderstanding you can just declare the global variable in lua in the module (leaving out the local keyword) instead of adding it to vim.g. It will be a global variable in both cases but to me the intent is more clear.
Sounds good, I'll give that a try 👍
No rush on this, I'm not upset. Just pinging you so it shows up in your email or something.
@AckslD switching off of vim.g is working well. Thank you
@AckslD anything else?
I see. Do I understand correctly that this does not actually create the venv but only install dependencies? Maybe the names should then be rephrased as by auto_create...venv I thought it would also create the venv if it didn't exist?
Also are currently the dependencies installed every time?
This does create the venv
Dependencies are "installed" everytime when changing venv, but if dependencies are already installed both pip and pdm will just quickly resolve them as "already existing"
@AckslD ready to merge?
Thanks @joshzcold! Trying it out myself a bit more thoroughly it works nice! I'd say it looks good now and would be happy to merge.
One question about intended behavior. Let's say I'm in some directory and call auto_venv which sets up the venv. Then I might pick another one using the picker. If I now call auto_venv it won't change the venv as the directory has not changed. Is that intended? Since if I go to some other directory, call auto_venv and then back again it will enable the original venv.
@AckslD yeah I think I like that behavior.
This would make it if you don't want the auto created venv and you picked an venv, the plugin wouldn't fight you during your session to switch it back.
Which sometimes I do use the picker and I wouldn't want auto_venv to set it back as a open files.
Sounds good! Thanks for sharing the nice feature and your patience, sorry again for taking so much time.