Emacs Editor integration support
Problem description
For launching the REPL ((+python/open-ipython-repl)) in the correct virtual environment, and for having the LSP detect the installed modules in the virtual env.
That would be great! Unfortunately none of us are real Emacs experts. Are there ways that you could help us out?
Emacs has a very good support for conda envs: http://github.com/necaris/conda.el
The nice thing is that conda activate amounts to updating env vars. This is what the Emacs conda-env-activate does. I suppose that pixi works the same way, so adapting what Emacs conda-mode does should not be difficult.
I will start experimenting with pixi soon and I am an Emacs user, so I will have a look at this and report back if I produce something useful.
The equivalent of conda activate environment_name is eval "$(pixi shell-hook --manifest-path /path/to/pixi.toml)"
Actually, there is nothing to do!
Since pixi installs a conda environment, Emacs’ conda-mode can be used as such. Just use conda-env-activate-path and all paths are set:
- if you
M-x run-pythonfrom a python buffer, il will run the correct interpreter - the same goes for LSP clients (I use eglot, I haven’t tested with lsp-mode)
- Emacs’ compile mode will also use the correct env. I use it to run mypy, pylint, pytest, etc. or standard Makfiles with different targets.
And best of all, since all Emacs commands use the current buffer’s directory as base dir for running, you can use pixi’s commands too with either shell-command (M-!) or compile (C-c c).
So, at least for me, Emacs supports pixi out of the box with conda-mode.
Hello,
at the risk of "shameless self-promotion", I updated snakemacs, my fully conda-based emacs setup to pixi. My setup is mainly targeted at Python/Jupyter development with multiple pixi environments, however it should not be hard to adapt to other languages, e.g., R.
The pixi environments are tracked using emacs-pet (with [a small caveat regarding the provision of pixi environment-aware IDE features via lsp-pyright).
There is just a small caveat in that I did not manage to build emacs-zmq using the build dependencies as pixi global tools, I am happy to share compilation errors if anyone may help debugging.
Best, Martí