aboutsummaryrefslogtreecommitdiffstats
path: root/templates/python-project-dir-locals.el
blob: 9f474dd3e7a2d03f7a3be3500967a1096c3a9790 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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)))))