aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md31
-rw-r--r--emacs.el12
-rw-r--r--templates/python-project-dir-locals.el18
3 files changed, 58 insertions, 3 deletions
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 <libs>
+cp templates/python-project-dir-locals.el <project>/.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
diff --git a/emacs.el b/emacs.el
index 9cd984b..748f44c 100644
--- a/emacs.el
+++ b/emacs.el
@@ -262,8 +262,12 @@
;;; ============================================================================
(use-package eglot
+ ;; NOTE: python-mode is deliberately NOT hooked here. Mode hooks run
+ ;; before .dir-locals.el applies, so this would always connect to the
+ ;; system pylsp. Python eglot is started per-project from
+ ;; .dir-locals.el (micromamba envs) -- see emacs_setup README.
:hook (((clojure-mode clojurec-mode clojurescript-mode
- java-mode scala-mode python-mode) . eglot-ensure)
+ java-mode scala-mode) . eglot-ensure)
((cider-mode eglot-managed-mode) . eglot-disable-in-cider))
:preface
(defun eglot-disable-in-cider ()
@@ -639,6 +643,12 @@
(put 'upcase-region 'disabled nil)
+;; Packages like go-mode reference lsp-mode/eglot functions they don't
+;; require; native-comp warnings about those are harmless noise. Keep them
+;; out of *Warnings*. (Must come AFTER custom-set-variables above, which
+;; rewrites warning-suppress-types.)
+(add-to-list 'warning-suppress-types '(native-compiler))
+
;;; PSL tree-sitter mode
(add-to-list 'load-path "~/.emacs.d/psl-ts-mode")
(require 'psl-ts-mode)
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)))))