aboutsummaryrefslogtreecommitdiffstats
path: root/templates/python-project-dir-locals.el
diff options
context:
space:
mode:
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)))))