diff options
| -rw-r--r-- | lisp/progmodes/eglot.el | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 82cb95392fb..0b5720ae440 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el | |||
| @@ -4320,6 +4320,18 @@ at point. With prefix argument, prompt for ACTION-KIND." | |||
| 4320 | (defvar eglot-watch-files-outside-project-root t | 4320 | (defvar eglot-watch-files-outside-project-root t |
| 4321 | "If non-nil, allow watching files outside project root") | 4321 | "If non-nil, allow watching files outside project root") |
| 4322 | 4322 | ||
| 4323 | (defun eglot--list-directories (dir) | ||
| 4324 | (with-temp-buffer | ||
| 4325 | (condition-case oops | ||
| 4326 | (call-process find-program nil t nil dir "-type" "d" "-print0") | ||
| 4327 | (error | ||
| 4328 | (eglot--warn "Can't list directories in %s: %s" dir oops))) | ||
| 4329 | (cl-loop initially (goto-char (point-min)) | ||
| 4330 | for start = (point) while (search-forward "\0" nil t) | ||
| 4331 | collect (expand-file-name | ||
| 4332 | (buffer-substring-no-properties start (1- (point))) | ||
| 4333 | dir)))) | ||
| 4334 | |||
| 4323 | (defun eglot--watch-globs (server id globs &optional base-path) | 4335 | (defun eglot--watch-globs (server id globs &optional base-path) |
| 4324 | "Set up file watching for files matching GLOBS under BASE-PATH. | 4336 | "Set up file watching for files matching GLOBS under BASE-PATH. |
| 4325 | GLOBS is a list of (COMPILED-GLOB . KIND) pairs, where COMPILED-GLOB | 4337 | GLOBS is a list of (COMPILED-GLOB . KIND) pairs, where COMPILED-GLOB |
| @@ -4327,10 +4339,17 @@ is a compiled glob predicate and KIND is a bitmask of change types. | |||
| 4327 | BASE-PATH is the directory to watch (nil means entire project). | 4339 | BASE-PATH is the directory to watch (nil means entire project). |
| 4328 | Returns success status for SERVER and registration ID." | 4340 | Returns success status for SERVER and registration ID." |
| 4329 | (let* ((project (eglot--project server)) | 4341 | (let* ((project (eglot--project server)) |
| 4330 | (dirs (delete-dups | 4342 | (root (project-root project)) |
| 4331 | (mapcar #'file-name-directory | 4343 | (dirs (if (and base-path |
| 4332 | (project-files project (and base-path | 4344 | (not (file-in-directory-p base-path root))) |
| 4333 | (list base-path)))))) | 4345 | ;; Outside root, use faster find-based listing |
| 4346 | (eglot--list-directories base-path) | ||
| 4347 | ;; Inside project or entire project: use project-files | ||
| 4348 | ;; which respects ignores | ||
| 4349 | (delete-dups | ||
| 4350 | (mapcar #'file-name-directory | ||
| 4351 | (project-files project (and base-path | ||
| 4352 | (list base-path))))))) | ||
| 4334 | (success nil)) | 4353 | (success nil)) |
| 4335 | (cl-labels | 4354 | (cl-labels |
| 4336 | ((handle-event (event) | 4355 | ((handle-event (event) |