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. --- templates/python-project-dir-locals.el | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 templates/python-project-dir-locals.el (limited to 'templates') diff --git a/templates/python-project-dir-locals.el b/templates/python-project-dir-locals.el new file mode 100644 index 0000000..9f474dd --- /dev/null +++ b/templates/python-project-dir-locals.el @@ -0,0 +1,18 @@ +;;; Template .dir-locals.el for micromamba-based Python projects. +;;; Copy into the project root as .dir-locals.el, replace ENV_NAME and +;;; ENVPATH, add packages (e.g. python-lsp-server) to the env, done. +;;; +;;; micromamba create -n ENV_NAME -c conda-forge python=3.12 \ +;;; python-lsp-server +;;; cp this-file /.dir-locals.el # then edit env name/path + +((python-mode + . ((python-shell-interpreter . "ENVPATH/bin/python") + (python-shell-interpreter-args . "-i") + ;; Uncomment only if the folder is NOT a git repo: + ;; (eval . (add-hook 'project-find-functions + ;; (lambda (_) (cons 'transient default-directory)) nil t)) + (eval . (setq-local exec-path (cons "ENVPATH/bin" exec-path))) + (eval . (setq-local eglot-server-programs + '(((python-mode python-ts-mode) . ("ENVPATH/bin/pylsp"))))) + (eval . (eglot-ensure))))) -- cgit v1.3