pixi icon indicating copy to clipboard operation
pixi copied to clipboard

Emacs Editor integration support

Open tsoernes opened this issue 1 year ago • 5 comments

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.

tsoernes avatar Sep 26 '24 13:09 tsoernes

That would be great! Unfortunately none of us are real Emacs experts. Are there ways that you could help us out?

wolfv avatar Sep 26 '24 14:09 wolfv

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.

gdindi avatar Oct 15 '24 11:10 gdindi

The equivalent of conda activate environment_name is eval "$(pixi shell-hook --manifest-path /path/to/pixi.toml)"

ruben-arts avatar Oct 16 '24 07:10 ruben-arts

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-python from 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.

gdindi avatar Oct 17 '24 14:10 gdindi

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í

martibosch avatar Nov 02 '25 09:11 martibosch