Skip to content

Commit

Permalink
Per joaotavora/eglot#697: Use project-files to know which directory w…
Browse files Browse the repository at this point in the history
…atchers 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 <dgutov@yandex.ru> for the idea.

* eglot.el (eglot--directories-recursively): Remove.
  • Loading branch information
joaotavora committed May 26, 2021
1 parent ceff167 commit c1554a8
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions lisp/progmodes/eglot.el
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
;;;
Expand Down

0 comments on commit c1554a8

Please sign in to comment.