[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/eglot 35597d2 22/22: Handle (un)registerCapability requ
From: |
João Távora |
Subject: |
[elpa] externals/eglot 35597d2 22/22: Handle (un)registerCapability requests via generic functions |
Date: |
Sat, 5 Jan 2019 09:31:05 -0500 (EST) |
branch: externals/eglot
commit 35597d262b53bde52faa46ee6ae8c597d93114e8
Author: João Távora <address@hidden>
Commit: João Távora <address@hidden>
Handle (un)registerCapability requests via generic functions
* eglot.el (Version): Bump to 1.4
(eglot-register-capability, eglot-unregister-capability): New
generic functions.
(eglot--register-unregister): Call eglot-register-capability,
eglot-unregister-capability.
(eglot-register-capability s (eql
workspace/didChangeWatchedFiles)): Rename from
eglot--register-workspace/didChangeWatchedFiles.
(eglot-unregister-capability s (eql
workspace/didChangeWatchedFiles)): Rename from
eglot--unregister-workspace/didChangeWatchedFiles.
---
eglot.el | 34 ++++++++++++++++++++++++++--------
1 file changed, 26 insertions(+), 8 deletions(-)
diff --git a/eglot.el b/eglot.el
index 53e60fd..031a657 100644
--- a/eglot.el
+++ b/eglot.el
@@ -2,7 +2,7 @@
;; Copyright (C) 2018 Free Software Foundation, Inc.
-;; Version: 1.3
+;; Version: 1.4
;; Author: João Távora <address@hidden>
;; Maintainer: João Távora <address@hidden>
;; URL: https://github.com/joaotavora/eglot
@@ -440,6 +440,20 @@ treated as in `eglot-dbind'."
"JSON object to send under `initializationOptions'"
(:method (_s) nil)) ; blank default
+(cl-defgeneric eglot-register-capability (server method id &rest params)
+ "Ask SERVER to register capability METHOD marked with ID."
+ (:method
+ (_s method _id &rest _params)
+ (eglot--warn "Server tried to register unsupported capability `%s'"
+ method)))
+
+(cl-defgeneric eglot-unregister-capability (server method id &rest params)
+ "Ask SERVER to register capability METHOD marked with ID."
+ (:method
+ (_s method _id &rest _params)
+ (eglot--warn "Server tried to unregister unsupported capability `%s'"
+ method)))
+
(cl-defgeneric eglot-client-capabilities (server)
"What the EGLOT LSP client supports for SERVER."
(:method (_s)
@@ -1423,12 +1437,14 @@ COMMAND is a symbol naming the command."
(cl-defun eglot--register-unregister (server things how)
"Helper for `registerCapability'.
-THINGS are either registrations or unregisterations."
+THINGS are either registrations or unregisterations (sic)."
(cl-loop
for thing in (cl-coerce things 'list)
do (eglot--dbind ((Registration) id method registerOptions) thing
- (apply (intern (format "eglot--%s-%s" how method))
- server :id id registerOptions))))
+ (apply (cl-ecase how
+ (register 'eglot-register-capability)
+ (unregister 'eglot-unregister-capability))
+ server (intern method) id registerOptions))))
(cl-defmethod eglot-handle-request
(server (_method (eql client/registerCapability)) &key registrations)
@@ -2243,9 +2259,10 @@ If SKIP-SIGNATURE, don't try to send
textDocument/signatureHelp."
for result = (replace-regexp-in-string pattern rep target)
finally return result))
-(cl-defun eglot--register-workspace/didChangeWatchedFiles (server &key id
watchers)
+(cl-defmethod eglot-register-capability
+ (server (method (eql workspace/didChangeWatchedFiles)) id &key watchers)
"Handle dynamic registration of workspace/didChangeWatchedFiles"
- (eglot--unregister-workspace/didChangeWatchedFiles server :id id)
+ (eglot-unregister-capability server method id)
(let* (success
(globs (mapcar (eglot--lambda ((FileSystemWatcher) globPattern)
globPattern)
@@ -2280,9 +2297,10 @@ If SKIP-SIGNATURE, don't try to send
textDocument/signatureHelp."
`(:message ,(format "OK, watching %s watchers"
(length watchers)))))
(unless success
- (eglot--unregister-workspace/didChangeWatchedFiles server :id
id))))))
+ (eglot-unregister-capability server method id))))))
-(cl-defun eglot--unregister-workspace/didChangeWatchedFiles (server &key id)
+(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))
- [elpa] externals/eglot 64da240 19/22: Fix #196: run connection hooks with proper dir-locals, (continued)
- [elpa] externals/eglot 64da240 19/22: Fix #196: run connection hooks with proper dir-locals, João Távora, 2019/01/05
- [elpa] externals/eglot af9dcad 10/22: Take over Flymake and Eldoc completely while managing buffers, João Távora, 2019/01/05
- [elpa] externals/eglot 5b9a164 01/22: Per #180: frame lsp-mode.el comparison as historical even more evidently, João Távora, 2019/01/05
- [elpa] externals/eglot 7b0d845 17/22: Close #195: remove a hard dependency on flymake-mode, João Távora, 2019/01/05
- [elpa] externals/eglot 923cbbe 08/22: Don't make bogus responses to client/(Un)RegisterCapability, João Távora, 2019/01/05
- [elpa] externals/eglot 85711cc 11/22: * eglot.el (Package-Requires): Require jsonrpc 1.0.7., João Távora, 2019/01/05
- [elpa] externals/eglot 1e1665e 06/22: Rewrite eglot--sig-info a bit for readability, João Távora, 2019/01/05
- [elpa] externals/eglot e65792f 18/22: Close #197: allow read-only modes for markup rendering, João Távora, 2019/01/05
- [elpa] externals/eglot c5dea9a 20/22: * eglot.el (eglot-workspace-configuration): Safe when listp., João Távora, 2019/01/05
- [elpa] externals/eglot 83f7f84 21/22: Appease checkdoc, João Távora, 2019/01/05
- [elpa] externals/eglot 35597d2 22/22: Handle (un)registerCapability requests via generic functions,
João Távora <=