From 0fb377c0576b8e5269ab3e18b2966582bd750983 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Wed, 17 Sep 2025 13:32:20 -0400 Subject: [PATCH] fix(tramp): direct-async + lsp-mode/eglot interop Neither lsp-mode nor eglot work over tramp with direct-async on, but I don't want to disable direct-async globally just for lsp-mode/eglot users, so I try to disable it solely for their stdio processes. More testing is needed to weed out edge cases that may result from this. Ref: emacs-lsp/lsp-mode#4573 Fix: #8510 --- modules/emacs/tramp/config.el | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/modules/emacs/tramp/config.el b/modules/emacs/tramp/config.el index 2c2ead50b..89dc813bf 100644 --- a/modules/emacs/tramp/config.el +++ b/modules/emacs/tramp/config.el @@ -32,6 +32,26 @@ 'remote-direct-async-process)) +;;;###package lsp-mode +;; HACK: lsp-mode over TRAMP doesn't work with direct async, so force it off for +;; LSP stdio connections. +(defadvice! +tramp--disable-direct-async-for-lsp-stdio-a (plist) + :filter-return #'lsp-stdio-connection + (let ((connect-fn (plist-get plist :connect))) + (plist-put plist :connect + (lambda (&rest args) + (letf! ((#'tramp-direct-async-process-p #'ignore)) + (apply connect-fn args)))))) + + +;;;###package eglot +;; HACK: Same deal with eglot. +(defadvice! +tramp--disable-direct-async-for-eglot-a (fn &rest args) + :around #'eglot--connect + (letf! ((#'tramp-direct-async-process-p #'ignore)) + (apply fn args))) + + ;; See magit/magit#5220 (after! magit (setq magit-tramp-pipe-stty-settings 'pty))