to look up issue github#1234, go to
https://github.com/joaotavora/eglot/issues/1234.
+\f
+* Changes in upcoming Eglot
+
+** Optimized file-watching capability
+
+Some servers, like the Pyright language server, issue too many file
+watching requests. This change slightly reduces the number of file
+watcher objects requested from the operating system, which can be a
+problem, particularly on Mac OS. See github#1228 and github#1226.
+
\f
* Changes in Eglot 1.15 (29/4/2023)
:documentation "Generalized boolean inhibiting auto-reconnection if true."
:accessor eglot--inhibit-autoreconnect)
(file-watches
- :documentation "Map ID to list of WATCHES for `didChangeWatchedFiles'."
+ :documentation "Map (DIR -> (WATCH ID1 ID2...)) for `didChangeWatchedFiles'."
:initform (make-hash-table :test #'equal) :accessor eglot--file-watches)
(managed-buffers
:documentation "List of buffers managed by server."
(eglot-autoshutdown nil))
(eglot--when-live-buffer buffer (eglot--managed-mode-off))))
;; Kill any expensive watches
- (maphash (lambda (_id watches)
- (mapcar #'file-notify-rm-watch watches))
+ (maphash (lambda (_dir watch-and-ids)
+ (file-notify-rm-watch (car watch-and-ids)))
(eglot--file-watches server))
;; Kill any autostarted inferior processes
(when-let (proc (eglot--inferior-process server))
(handle-event `(,desc 'created ,file1)))))))
(unwind-protect
(progn
- (dolist (dir dirs-to-watch)
- (when (file-readable-p dir)
- (push (file-notify-add-watch dir '(change) #'handle-event)
- (gethash id (eglot--file-watches server)))))
+ (cl-loop for dir in dirs-to-watch
+ for probe =
+ (and (file-readable-p dir)
+ (or (gethash dir (eglot--file-watches server))
+ (puthash dir (list (file-notify-add-watch dir '(change) #'handle-event))
+ (eglot--file-watches server))))
+ when probe do (push id (cdr probe)))
(setq
success
`(:message ,(format "OK, watching %s directories in %s watchers"
(cl-defmethod eglot-unregister-capability
(server (_method (eql workspace/didChangeWatchedFiles)) id)
"Handle dynamic unregistration of workspace/didChangeWatchedFiles."
- (mapc #'file-notify-rm-watch (gethash id (eglot--file-watches server)))
- (remhash id (eglot--file-watches server))
+ (maphash (lambda (dir watch-and-ids)
+ (when (member id (cdr watch-and-ids))
+ (setcdr watch-and-ids (delete id (cdr watch-and-ids)))
+ (when (null (cdr watch-and-ids))
+ (file-notify-rm-watch (car watch-and-ids))
+ (remhash dir (eglot--file-watches server)))))
+ (eglot--file-watches server))
(list t "OK"))
\f