3 ms·
I've had a good experience with direnv[1] and emacs-direnv[2]. Direnv can automatically load an environment when you enter a directory, so it automatically "op
by tikhonj 4y ago
I've had a good experience with direnv[1] and emacs-direnv[2].
Direnv can automatically load an environment when you enter a directory, so it automatically "opens" virtualenvs/nix shells/etc. The Emacs direnv mode ensures that each buffer sees the direnv mode for its project directory.
I've found this to be a great compromise between automatic behavior on the one hand and transparency + control on the other—I get the right environment loaded automatically very consistently and, if something goes wrong, I can open a shell and poke around to see what's going on (is my nix shell messed up? is the right tool not loaded via direnv? etc). The only time I need to do anything manually is if I make a change to the environment and need to update Emacs about it, in which case I just run M-x direnv-update-environment.
Once I got this set up, I can just rely on executable-find to check for (and find) exactly the right tool on a per-project basis—no more worrying about global or seeing the wrong version of a tool. This also made it easy to do stuff like only run formatting if the corresponding tool is available: I add hooks to various programming language modes that only turn on lsp/formatting/etc if executable-find sees the corresponding executable.
Compared to the hassle I've had to go through helping my colleagues debug VSCode not seeing the right conda environment, virtualenv or the right version of various tools, Emacs + direnv has been a far nicer and more consistent experience.
[1]: https://direnv.net/ https://direnv.net/
[2]: https://github.com/wbolster/emacs-direnv https://github.com/wbolster/emacs-direnv
- mcbuilder 4y agoYeah, I've been doing the same thing. direnv is such a KISS tool, and is language agnostic as well. My prior experience with LSP wasn't exactly pain free, so it's definitely smoothing a rough patch. Having Elgot in master is great if makes the out of box experience work. I use VS code for a couple days and I will already want to go back to Emacs, and having a good LSP experience is pretty important for either.