[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/eglot 3a1ff72 04/24: Introduce new API methods for expe
From: |
João Távora |
Subject: |
[elpa] externals/eglot 3a1ff72 04/24: Introduce new API methods for experimental clients to use |
Date: |
Sat, 26 May 2018 14:31:13 -0400 (EDT) |
branch: externals/eglot
commit 3a1ff72e2f0c862b668e5c88bf696aba653b31e3
Author: João Távora <address@hidden>
Commit: João Távora <address@hidden>
Introduce new API methods for experimental clients to use
Should help Josh Elsasser implement pull request #6.
* eglot.el (eglot--obj): Move upwards in file.
(eglot-server-ready-p): Tweak comment.
(eglot-initialization-options): New API defgeneric..
(eglot-client-capabilities): New API defgeneric.
(eglot--client-capabilities): Remove.
(eglot--connect): Call new API methods here.
---
eglot.el | 85 +++++++++++++++++++++++++++++++++-------------------------------
1 file changed, 44 insertions(+), 41 deletions(-)
diff --git a/eglot.el b/eglot.el
index 43cda1b..5e9bdc3 100644
--- a/eglot.el
+++ b/eglot.el
@@ -115,12 +115,19 @@ lasted more than that many seconds."
;;; API
;;;
+(defmacro eglot--obj (&rest what)
+ "Make WHAT a JSON object suitable for `json-encode'."
+ (declare (debug (&rest form)))
+ ;; FIXME: not really API. Should it be?
+ ;; FIXME: maybe later actually do something, for now this just fixes
+ ;; the indenting of literal plists.
+ `(list ,@what))
+
(cl-defgeneric eglot-server-ready-p (server what) ;; API
"Tell if SERVER is ready for WHAT in current buffer.
If it isn't, a deferrable `eglot--async-request' *will* be
deferred to the future."
- (:method (_s _what)
- "Normally not ready if outstanding changes."
+ (:method (_s _what) "Normally ready if no outstanding changes."
(not (eglot--outstanding-edits-p))))
(cl-defgeneric eglot-handle-request (server method id &rest params)
@@ -129,6 +136,35 @@ deferred to the future."
(cl-defgeneric eglot-handle-notification (server method id &rest params)
"Handle SERVER's METHOD notification with PARAMS.")
+(cl-defgeneric eglot-initialization-options (server)
+ "JSON object to send under `initializationOptions'"
+ (:method (_s) nil)) ; blank default
+
+(cl-defgeneric eglot-client-capabilities (server)
+ "What the EGLOT LSP client supports for SERVER."
+ (:method (_s)
+ (eglot--obj
+ :workspace (eglot--obj
+ :applyEdit t
+ :workspaceEdit `(:documentChanges :json-false)
+ :didChangeWatchesFiles `(:dynamicRegistration t)
+ :symbol `(:dynamicRegistration :json-false))
+ :textDocument
+ (eglot--obj
+ :synchronization (eglot--obj
+ :dynamicRegistration :json-false
+ :willSave t :willSaveWaitUntil t :didSave t)
+ :completion `(:dynamicRegistration :json-false)
+ :hover `(:dynamicRegistration :json-false)
+ :signatureHelp `(:dynamicRegistration :json-false)
+ :references `(:dynamicRegistration :json-false)
+ :definition `(:dynamicRegistration :json-false)
+ :documentSymbol `(:dynamicRegistration :json-false)
+ :documentHighlight `(:dynamicRegistration :json-false)
+ :rename `(:dynamicRegistration :json-false)
+ :publishDiagnostics `(:relatedInformation :json-false))
+ :experimental (eglot--obj))))
+
;;; Process management
(defvar eglot--servers-by-project (make-hash-table :test #'equal)
@@ -223,13 +259,6 @@ CONTACT is in `eglot'. Returns a process object."
(let ((inhibit-read-only t)) (erase-buffer) (read-only-mode t)))
proc))
-(defmacro eglot--obj (&rest what)
- "Make WHAT a suitable argument for `json-encode'."
- (declare (debug (&rest form)))
- ;; FIXME: maybe later actually do something, for now this just fixes
- ;; the indenting of literal plists.
- `(list ,@what))
-
(defun eglot--all-major-modes ()
"Return all know major modes."
(let ((retval))
@@ -238,29 +267,6 @@ CONTACT is in `eglot'. Returns a process object."
(push sym retval))))
retval))
-(defun eglot--client-capabilities ()
- "What the EGLOT LSP client supports."
- (eglot--obj
- :workspace (eglot--obj
- :applyEdit t
- :workspaceEdit `(:documentChanges :json-false)
- :didChangeWatchesFiles `(:dynamicRegistration t)
- :symbol `(:dynamicRegistration :json-false))
- :textDocument (eglot--obj
- :synchronization (eglot--obj
- :dynamicRegistration :json-false
- :willSave t :willSaveWaitUntil t :didSave
t)
- :completion `(:dynamicRegistration :json-false)
- :hover `(:dynamicRegistration :json-false)
- :signatureHelp `(:dynamicRegistration :json-false)
- :references `(:dynamicRegistration :json-false)
- :definition `(:dynamicRegistration :json-false)
- :documentSymbol `(:dynamicRegistration :json-false)
- :documentHighlight `(:dynamicRegistration :json-false)
- :rename `(:dynamicRegistration :json-false)
- :publishDiagnostics `(:relatedInformation :json-false))
- :experimental (eglot--obj)))
-
(defvar eglot-connect-hook nil "Hook run after connecting in
`eglot--connect'.")
(defun eglot--connect (project managed-major-mode contact server-class)
@@ -294,15 +300,12 @@ class SERVER-CLASS."
(eglot--request
server
:initialize
- (eglot--obj :processId (unless (eq (process-type proc)
- 'network)
- (emacs-pid))
- :capabilities(eglot--client-capabilities)
- :rootPath (expand-file-name
- (car (project-roots project)))
- :rootUri (eglot--path-to-uri
- (car (project-roots project)))
- :initializationOptions []))
+ (eglot--obj
+ :processId (unless (eq (process-type proc) 'network) (emacs-pid))
+ :capabilities (eglot-client-capabilities)
+ :rootPath (expand-file-name (car (project-roots project)))
+ :rootUri (eglot--path-to-uri (car (project-roots project)))
+ :initializationOptions (eglot-initialization-options server)))
(setf (eglot--capabilities server) capabilities)
(setf (eglot--status server) nil)
(dolist (buffer (buffer-list))
- [elpa] externals/eglot updated (24877ae -> 897cbc3), João Távora, 2018/05/26
- [elpa] externals/eglot d673cf7 07/24: Increase test timeout in hopes of convincing Travis CI, João Távora, 2018/05/26
- [elpa] externals/eglot 89baadf 05/24: Fix indentation broken by the defclass monster commit, João Távora, 2018/05/26
- [elpa] externals/eglot 1ef8228 01/24: Introduce eglot-handle-request and eglot-handle-notification as API, João Távora, 2018/05/26
- [elpa] externals/eglot 3a1ff72 04/24: Introduce new API methods for experimental clients to use,
João Távora <=
- [elpa] externals/eglot 9c87771 12/24: Introduce eglot--debug for unimportant messages, João Távora, 2018/05/26
- [elpa] externals/eglot 8d4c2c3 13/24: Demote unvisited diagnostics logging to debug level, João Távora, 2018/05/26
- [elpa] externals/eglot 85c5353 11/24: Add cquery support for C/C++ projects, João Távora, 2018/05/26
- [elpa] externals/eglot d40a458 14/24: Log debug messages through eglot--debug, João Távora, 2018/05/26
- [elpa] externals/eglot 17a3257 03/24: Do Rust's RLS hack properly with new class-based API, João Távora, 2018/05/26
- [elpa] externals/eglot 3aa2958 06/24: Add a complex RLS test, João Távora, 2018/05/26
- [elpa] externals/eglot 07078da 08/24: Rework eglot-tests.el for better debuggability, João Távora, 2018/05/26
- [elpa] externals/eglot 0462130 15/24: New RLS tests, João Távora, 2018/05/26
- [elpa] externals/eglot e1d7ff3 09/24: Disable file-watching tests on Travis, João Távora, 2018/05/26
- [elpa] externals/eglot c8e7ab0 16/24: Don't rely on Flymake's idle timer for textDocument/didChange, João Távora, 2018/05/26