From b1a379cd774f40f6709fdfbb5c469fc317f22f8d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jo=C3=A3o=20T=C3=A1vora?= Date: Wed, 26 May 2021 18:51:30 +0100 Subject: [PATCH] Use project-files to know which directory watchers to skip The directory-finding logic is probably a bit slower than using eglot--directories-recursively, but since it honours `.gitignores` and ignores more directories it's much faster overall. And guaranteed to create less watchers. Thanks to Dmitry Gutov for the idea. * eglot.el (eglot--directories-recursively): Remove. GitHub-reference: per https://github.com/joaotavora/eglot/issues/697 --- lisp/progmodes/eglot.el | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 4c47ad004bb..4ead874eec5 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -2777,7 +2777,9 @@ at point. With prefix argument, prompt for ACTION-KIND." (eglot--glob-compile globPattern t t)) watchers)) (dirs-to-watch - (eglot--directories-recursively default-directory))) + (delete-dups (mapcar #'file-name-directory + (project-files + (eglot--project server)))))) (cl-labels ((handle-event (event) @@ -2878,15 +2880,6 @@ If NOERROR, return predicate, else erroring function." (when (eq ?! (aref arg 1)) (aset arg 1 ?^)) `(,self () (re-search-forward ,(concat "\\=" arg)) (,next))) -(defun eglot--directories-recursively (&optional dir) - "Because `directory-files-recursively' isn't complete in 26.3." - (cons (setq dir (expand-file-name (or dir default-directory))) - (cl-loop with default-directory = dir - with completion-regexp-list = '("^[^.]") - for f in (file-name-all-completions "" dir) - if (and (file-directory-p f) (not (string= "node_modules/" f))) - append (eglot--directories-recursively f)))) - ;;; Rust-specific ;;; -- 2.39.2