perf: optimize tramp + projectile integration

Reduce how much projectile hits the server in TRAMP buffers by:

- Not looking for fd/fdfind (just use the VCS-specific commands
  projectile provides and assume they're present on the remote).
- Not walking up the directory tree to display the project name in the
  mode line.
- Reducing TRAMP file-cache misses.
- Reducing how chatty tramp is about its connections.

Fix #5360
This commit is contained in:
Henrik Lissner 2021-08-10 17:00:25 -04:00
parent 44412955cc
commit 0b5243c12c
2 changed files with 24 additions and 5 deletions

View file

@ -411,6 +411,16 @@ files, so this replace calls to `pp' with the much faster `prin1'."
(server-start))) (server-start)))
(after! tramp
(setq remote-file-name-inhibit-cache 60
tramp-completion-reread-directory-timeout 60
tramp-verbose 1
vc-ignore-dir-regexp (format "%s\\|%s\\|%s"
vc-ignore-dir-regexp
tramp-file-name-regexp
"[/\\\\]node_modules")))
;; ;;
;;; Packages ;;; Packages

View file

@ -36,7 +36,15 @@ debian, and derivatives). On most it's 'fd'.")
projectile-kill-buffers-filter 'kill-only-files projectile-kill-buffers-filter 'kill-only-files
projectile-known-projects-file (concat doom-cache-dir "projectile.projects") projectile-known-projects-file (concat doom-cache-dir "projectile.projects")
projectile-ignored-projects '("~/") projectile-ignored-projects '("~/")
projectile-ignored-project-function #'doom-project-ignored-p) projectile-ignored-project-function #'doom-project-ignored-p
;; The original `projectile-default-mode-line' can be expensive over
;; TRAMP, so we gimp it in remote buffers.
projectile-mode-line-function
(lambda ()
(if (file-remote-p default-directory)
(projectile-default-mode-line)
"")))
(global-set-key [remap evil-jump-to-tag] #'projectile-find-tag) (global-set-key [remap evil-jump-to-tag] #'projectile-find-tag)
(global-set-key [remap find-tag] #'projectile-find-tag) (global-set-key [remap find-tag] #'projectile-find-tag)
@ -147,13 +155,14 @@ c) are not valid projectile projects."
;; HACK Don't rely on VCS-specific commands to generate our file lists. That's ;; HACK Don't rely on VCS-specific commands to generate our file lists. That's
;; 7 commands to maintain, versus the more generic, reliable and ;; 7 commands to maintain, versus the more generic, reliable and
;; performant `fd' or `ripgrep'. ;; performant `fd' or `ripgrep'.
(defadvice! doom--only-use-generic-command-a (vcs) (defadvice! doom--only-use-generic-command-a (fn vcs)
"Only use `projectile-generic-command' for indexing project files. "Only use `projectile-generic-command' for indexing project files.
And if it's a function, evaluate it." And if it's a function, evaluate it."
:override #'projectile-get-ext-command :around #'projectile-get-ext-command
(if (functionp projectile-generic-command) (if (and (functionp projectile-generic-command)
(not (file-remote-p default-directory)))
(funcall projectile-generic-command vcs) (funcall projectile-generic-command vcs)
projectile-generic-command)) (funcall fn vcs)))
;; `projectile-generic-command' doesn't typically support a function, but my ;; `projectile-generic-command' doesn't typically support a function, but my
;; `doom--only-use-generic-command-a' advice allows this. I do it this way so ;; `doom--only-use-generic-command-a' advice allows this. I do it this way so