aboutsummaryrefslogtreecommitdiffstats
path: root/templates/python-project-dir-locals.el
diff options
context:
space:
mode:
authorVaino Kauppila <vaino@vke.fi>2026-09-10 14:58:07 +0300
committerVaino Kauppila <vaino@vke.fi>2026-09-10 14:58:07 +0300
commite459fea00e71717df0ece58989986c641c4a2ff2 (patch)
treeddc50b1daaf226f38df4ff9707fb3e94bc30ae79 /templates/python-project-dir-locals.el
parente1b2af4e400ecae38fc8890879b91515ba3c2451 (diff)
downloademacs_setup-e459fea00e71717df0ece58989986c641c4a2ff2.tar.gz
emacs_setup-e459fea00e71717df0ece58989986c641c4a2ff2.zip
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.
Diffstat (limited to 'templates/python-project-dir-locals.el')
-rw-r--r--templates/python-project-dir-locals.el18
1 files changed, 18 insertions, 0 deletions
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 <your libraries>
+;;; cp this-file <project>/.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)))))