New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[REQUEST] Automatically activate a pipenv environment if available #1666
Comments
Ah, I was just working on this locally. I'm using |
That it doesn't already is actually a bug. I erroneously thought activating Per-buffer switching raises some concerns, however. I imagine something like |
This seems to work reasonably well:
This can get quite slow in some cases, since activating a virtualenv can trigger additional actions apart from setting |
However, it's not enough: when restoring a session, LSP mode is activated, but |
I'll look into restarting LSP servers when the python environment changes. I don't think this is acceptable on buffer switch, but it makes sense to do so upon a) first entering a python-mode buffer (calling |
Any news on this? |
This is of course not a solution to the issue at all, but I've personally starting preferring just opening an instance of Emacs through |
For anyone who needs a workaround I've managed to get virtual envs + autocomplete / imports fixed with the following command combinations in order. Please mind there might be a shorter way to do this, I just don't know it. I'll assume you already have opened your project in emacs:
That should get your imports, lints and other things inside your virtual env working just fine. |
Or just use direnv. Doom provides first class support for it with its And it's a lot less hassle than supporting the myriad permutations of python env managers out there. |
That sounds great :D I didn't know that module existed, my |
For the pipenv user, on a linux system install direnv. ( Add eval to ~/.bashrc --> Add .envrc to your project file but do allow the .envrc by issuing What goes inside .envrc? Check this out https://github.com/direnv/direnv/wiki/Python Do not forget to enable direnv in doom config and you are all set. |
☝️ This is so useful. I always have to run |
It would be really nice if
doom-emacs
tried to runpipenv-activate
on Python files.Rationale:
pipenv
is not availablelsp-mode
activates automatically for every file. If the language server is installed into a virtual environment,lsp-mode
will not find it without activated virtualenv.A possible complication is that while
lsp-mode
starts a language server per workspace,pyvenv
applies its configuration globally, so that something like apipenv-deactivate
+pipenv-activate
combo is needed every time a buffer is opened or switched to.The text was updated successfully, but these errors were encountered: