Commit 3aef3268c9ba

Vincent Demeester <vincent@sbr.pm>
2026-01-12 15:09:58
fix(emacs): prevent eglot auto-start on TRAMP remote files
- Add eglot-ensure-unless-tramp wrapper to check if file is remote - Only auto-start eglot for local files to prevent hangs - Apply to all language modes that use eglot (nix, rust, python, go, etc)
1 parent 3a5402c
Changed files (1)
tools
emacs
tools/emacs/init.el
@@ -709,21 +709,29 @@ minibuffer, even without explicitly focusing it."
       (remove-hook 'before-save-hook #'eglot-format-buffer 'local)))
   (declare-function eglot-format-buffer-on-save "init")
   (add-hook 'eglot-managed-mode-hook #'eglot-format-buffer-on-save)
+
+  ;; Don't auto-start eglot on TRAMP files (too slow/unreliable)
+  (defun eglot-ensure-unless-tramp ()
+    "Start eglot unless we're on a TRAMP remote file."
+    (unless (file-remote-p default-directory)
+      (eglot-ensure)))
+  (declare-function eglot-ensure-unless-tramp "init")
+
   :hook
   ;; (before-save . gofmt-before-save)
   ;; (before-save . eglot-format-buffer)
-  (nix-mode . eglot-ensure)
-  (nix-ts-mode . eglot-ensure)
-  (rust-mode . eglot-ensure)
-  (rust-ts-mode . eglot-ensure)
-  (python-mode . eglot-ensure)
-  (python-ts-mode . eglot-ensure)
-  (go-mode . eglot-ensure)
-  (go-ts-mode . eglot-ensure)
-  (sh-mode . eglot-ensure)
-  (sh-script-mode . eglot-ensure)
-  (org-mode . eglot-ensure)
-  (markdown-mode . eglot-ensure))
+  (nix-mode . eglot-ensure-unless-tramp)
+  (nix-ts-mode . eglot-ensure-unless-tramp)
+  (rust-mode . eglot-ensure-unless-tramp)
+  (rust-ts-mode . eglot-ensure-unless-tramp)
+  (python-mode . eglot-ensure-unless-tramp)
+  (python-ts-mode . eglot-ensure-unless-tramp)
+  (go-mode . eglot-ensure-unless-tramp)
+  (go-ts-mode . eglot-ensure-unless-tramp)
+  (sh-mode . eglot-ensure-unless-tramp)
+  (sh-script-mode . eglot-ensure-unless-tramp)
+  (org-mode . eglot-ensure-unless-tramp)
+  (markdown-mode . eglot-ensure-unless-tramp))
 
 (setq major-mode-remap-alist
       '((python-mode . python-ts-mode)
@@ -774,7 +782,7 @@ minibuffer, even without explicitly focusing it."
 
 (use-package lua-ts-mode
   :mode "\\.lua\\'"
-  :hook (lua-ts-mode . eglot-ensure))
+  :hook (lua-ts-mode . eglot-ensure-unless-tramp))
 
 (use-package nix-ts-mode
   :if (executable-find "nix")