swenv.nvim icon indicating copy to clipboard operation
swenv.nvim copied to clipboard

feat: Add new feature to auto create a venv directory and set

Open joshzcold opened this issue 1 year ago • 6 comments

  • 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

image

joshzcold avatar Jul 23 '24 22:07 joshzcold

@AckslD any thoughts? Is this something you would want in swenv or does it belong in a separate plugin that just calls swenv?

joshzcold avatar Aug 27 '24 01:08 joshzcold

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 avatar Aug 27 '24 11:08 AckslD

@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 avatar Sep 16 '24 15:09 joshzcold

@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.

AckslD avatar Sep 16 '24 15:09 AckslD

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.

joshzcold avatar Sep 16 '24 16:09 joshzcold

@AckslD switching off of vim.g is working well. Thank you

joshzcold avatar Sep 16 '24 16:09 joshzcold

@AckslD anything else?

joshzcold avatar Oct 15 '24 03:10 joshzcold

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"

joshzcold avatar Jan 09 '25 22:01 joshzcold

@AckslD ready to merge?

joshzcold avatar Jan 14 '25 18:01 joshzcold

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 avatar Jan 25 '25 16:01 AckslD

@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.

joshzcold avatar Jan 28 '25 00:01 joshzcold

Sounds good! Thanks for sharing the nice feature and your patience, sorry again for taking so much time.

AckslD avatar Jan 28 '25 08:01 AckslD