From e459fea00e71717df0ece58989986c641c4a2ff2 Mon Sep 17 00:00:00 2001 From: Vaino Kauppila Date: Thu, 10 Sep 2026 14:58:07 +0300 Subject: Python LSP via per-project micromamba envs; silence native-comp warnings - Drop python-mode from the global eglot hook: mode hooks run before .dir-locals.el applies, so it would always grab the system pylsp. Python eglot now starts per-project from .dir-locals.el pointing at the project's micromamba env (interpreter, exec-path, pylsp). - templates/python-project-dir-locals.el: copy+edit recipe for new projects. vkeHF is already wired to env vkehf. - Suppress (native-compiler) warnings: go-mode and friends reference lsp/eglot functions they don't require; harmless noise. Verified in a GUI session: opening vkeHF/superhet.py connects eglot and spawns ~/.local/share/mamba/envs/vkehf/bin/pylsp. --- README.md | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index 8b2718a..0f34329 100644 --- a/README.md +++ b/README.md @@ -43,12 +43,39 @@ Fixed in a follow-up commit: and hooks `lsp` into `verilog-mode`, but the binary is not installed, so opening Verilog files errored. Now registered only when the binary exists (`executable-find`). Install `verible` to re-enable. +3. **Harmless native-comp warnings** — packages like go-mode reference + lsp-mode/eglot functions they don't require; the resulting + `(native-compiler)` warnings cluttered *Warnings*. Now suppressed + (`warning-suppress-types`, after the custom block). + +## Python: per-project micromamba environments + +Python LSP is deliberately NOT enabled globally (see the comment on the +eglot `use-package` form): mode hooks run before `.dir-locals.el` applies, +so a global hook would always connect to the system pylsp. Instead each +micromamba project carries a `.dir-locals.el` that points the interpreter, +`exec-path` and eglot at the env, then starts eglot. + +New project setup: + +```sh +micromamba create -n ENVNAME -c conda-forge python=3.12 python-lsp-server +cp templates/python-project-dir-locals.el /.dir-locals.el # edit env path +``` + +First time you open a file in the project, Emacs asks to trust the `eval` +forms — answer `!` (trust always). + +`~/Projects/vkeHF` is set up this way with env `vkehf` +(numpy, control, matplotlib, python-lsp-server); verified that eglot spawns +`~/.local/share/mamba/envs/vkehf/bin/pylsp`. Known quirks left as-is (deliberate-looking choices — revisit if annoying): - **`lsp-mode` and `eglot` are both active**: lsp-mode owns C/C++/Verilog/VHDL/ - LaTeX, eglot owns Java/Scala/Python/Clojure. The C/C++ overlap is noted in - the config itself. Works, but pick one eventually. + LaTeX, eglot owns Java/Scala/Clojure (Python is per-project, see above). + The C/C++ overlap is noted in the config itself. Works, but pick one + eventually. - **`jdtls` is not installed**, so Java files will fail to start eglot. Install `jdtls` (or drop java-mode from the eglot hook). - **`flycheck-c/c++-gcc-executable` is set to `/usr/bin/avr-gcc`** in -- cgit v1.3