From b83cd67751ecb8a1d08993f0751bc5d3dc480a24 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jo=C3=A3o=20T=C3=A1vora?= Date: Fri, 4 May 2018 15:19:19 +0100 Subject: [PATCH] Handle dynamic registration in general (but nothing specific yet) * eglot.el (eglot--server-client/registerCapability): Implement. (eglot--register-workspace/didChangeWatchedFiles): Dummy registrator. --- lisp/progmodes/eglot.el | 41 ++++++++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 68fe3e287a8..2b3f270ef9c 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -1003,15 +1003,28 @@ running. INTERACTIVE is t if called interactively." (cl-defun eglot--server-client/registerCapability (proc &key id registrations) "Handle notification client/registerCapability" - (mapc (lambda (reg) - (apply (cl-function - (lambda (&key _id _method _registerOptions) - ;;; TODO: handle this - )) - reg)) - registrations) - (eglot--reply proc id :error (eglot--obj :code -32601 - :message "sorry :-("))) + (catch 'done + (mapc + (lambda (reg) + (apply + (cl-function + (lambda (&key id method registerOptions) + (pcase-let* + ((handler-sym (intern (concat "eglot--register-" + method))) + (`(,ok ,message) + (and (functionp handler-sym) + (apply handler-sym proc :id id registerOptions)))) + (unless ok + (throw + 'done + (eglot--reply proc id + :error (eglot--obj + :code -32601 + :message (or message "sorry :-(")))))))) + reg)) + registrations) + (eglot--reply proc id :result (eglot--obj :message "OK")))) (defvar eglot--recent-before-changes nil "List of recent changes as collected by `eglot--before-change'.") @@ -1176,6 +1189,16 @@ Calls REPORT-FN maybe if server publishes diagnostics in time." ;; make the server report new diagnostics. (eglot--signal-textDocument/didChange)) + +;;; Dynamic registration +;;; +(cl-defun eglot--register-workspace/didChangeWatchedFiles + (_proc &key _id _watchers) + "Handle dynamic registration of workspace/didChangeWatchedFiles" + ;; TODO: file-notify-add-watch and + ;; file-notify-rm-watch can probably handle this + (list nil "Sorry, can't do this yet")) + ;;; Rust-specific ;;; -- 2.39.2