Files
doomemacs/modules/emacs/tramp/config.el
Henrik Lissner 0fb377c057 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
2025-09-17 15:55:55 -04:00

66 lines
2.3 KiB
EmacsLisp
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
;;; emacs/tramp/config.el -*- lexical-binding: t; -*-
;; Prefix tramp autosaves to prevent conflicts with local ones
(cl-pushnew (list "\\`/[^/]*:\\([^/]*/\\)*\\([^/]*\\)\\'"
(concat auto-save-list-file-prefix "tramp-\\2") t)
auto-save-file-name-transforms
:test #'equal)
(after! tramp
(setq remote-file-name-inhibit-cache 60
remote-file-name-inhibit-locks t
remote-file-name-inhibit-auto-save-visited t
tramp-copy-size-limit (* 1024 1024) ; 1mb
tramp-use-scp-direct-remote-copying t
tramp-completion-reread-directory-timeout 60
tramp-backup-directory-alist backup-directory-alist
tramp-auto-save-directory (concat doom-cache-dir "tramp-autosave/"))
(unless (featurep :system 'windows)
(setq tramp-default-method "ssh"))) ; faster than scp on Windows
;; See https://coredumped.dev/2025/06/18/making-tramp-go-brrrr.
(after! files-x
(connection-local-set-profile-variables
'remote-direct-async-process
'((tramp-direct-async-process . t)))
(connection-local-set-profiles
`(:application tramp :protocol "scp")
'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))
;; PERF: Newer versions of TRAMP will use SSH connection sharing for much faster
;; connections. These dont require you to reenter your password each time you
;; connect. The compile command disables this feature, so we want to turn it
;; back on.
(after! (tramp compile)
(remove-hook 'compilation-mode-hook #'tramp-compile-disable-ssh-controlmaster-options))