emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/eglot 8160cd4 071/139: Handle dynamic registration in g


From: João Távora
Subject: [elpa] externals/eglot 8160cd4 071/139: Handle dynamic registration in general (but nothing specific yet)
Date: Mon, 14 May 2018 09:54:56 -0400 (EDT)

branch: externals/eglot
commit 8160cd41fd7c0ff1ce436da2d1100f14f7c33efe
Author: João Távora <address@hidden>
Commit: João Távora <address@hidden>

    Handle dynamic registration in general (but nothing specific yet)
    
    * eglot.el (eglot--server-client/registerCapability): Implement.
    (eglot--register-workspace/didChangeWatchedFiles): Dummy registrator.
---
 eglot.el | 41 ++++++++++++++++++++++++++++++++---------
 1 file changed, 32 insertions(+), 9 deletions(-)

diff --git a/eglot.el b/eglot.el
index 68fe3e2..2b3f270 100644
--- a/eglot.el
+++ b/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'.")
@@ -1177,6 +1190,16 @@ Calls REPORT-FN maybe if server publishes diagnostics in 
time."
   (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
 ;;;
 (cl-defun eglot--server-window/progress



reply via email to

[Prev in Thread] Current Thread [Next in Thread]