[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/eglot 41f5922 137/139: Now send willSaveWaitUntil
From: |
Jo�o T�vora |
Subject: |
[elpa] externals/eglot 41f5922 137/139: Now send willSaveWaitUntil |
Date: |
Mon, 14 May 2018 09:55:11 -0400 (EDT) |
branch: externals/eglot
commit 41f5922c1b396c54b1ff2e74ed804328f361c9df
Author: João Távora <address@hidden>
Commit: João Távora <address@hidden>
Now send willSaveWaitUntil
* eglot.el (eglot--client-capabilities): Report willSaveWaitUntil.
(eglot--server-workspace/applyEdit): Fix docstring.
(eglot--signal-textDocument/willSave): Send willSaveWaitUntil
(eglot--signal-textDocument/didOpen)
(eglot--signal-textDocument/didClose): Don't eglot--obj.
(eglot--apply-text-edits): Simplify. Use current buffer.
(eglot--apply-workspace-edit): Use new eglot--apply-text-edits.
---
README.md | 6 +++---
eglot.el | 70 ++++++++++++++++++++++++++++++---------------------------------
2 files changed, 36 insertions(+), 40 deletions(-)
diff --git a/README.md b/README.md
index e5a2394..056065c 100644
--- a/README.md
+++ b/README.md
@@ -60,7 +60,7 @@ either:
(define-key eglot-mode-map (kbd "<f6>") 'xref-find-definitions)
```
-# Supported Protocol features
+# Supported Protocol features (3.6)
## General
- [x] initialize
@@ -85,14 +85,14 @@ either:
- [ ] workspace/didChangeConfiguration
- [ ] workspace/configuration (3.6.0)
- [ ] workspace/didChangeWatchedFiles
-- [x] workspace/symbol
+- [x] workspace/symbol is
- [x] workspace/applyEdit
## Text Synchronization
- [x] textDocument/didOpen
- [x] textDocument/didChange (incremental or full)
- [x] textDocument/willSave
-- [ ] textDocument/willSaveWaitUntil
+- [x] textDocument/willSaveWaitUntil
- [x] textDocument/didSave
- [x] textDocument/didClose
diff --git a/eglot.el b/eglot.el
index 6dc2213..eab7ce7 100644
--- a/eglot.el
+++ b/eglot.el
@@ -203,9 +203,7 @@ CONTACT is as `eglot--contact'. Returns a process object."
:textDocument (eglot--obj
:synchronization (eglot--obj
:dynamicRegistration :json-false
- :willSave t
- :willSaveWaitUntil :json-false
- :didSave t)
+ :willSave t :willSaveWaitUntil t :didSave
t)
:completion `(:dynamicRegistration :json-false)
:hover `(:dynamicRegistration :json-false)
:signatureHelp `(:dynamicRegistration :json-false)
@@ -1023,7 +1021,7 @@ called interactively."
(cl-defun eglot--server-workspace/applyEdit
(proc &key id _label edit)
- "Handle notification client/registerCapability"
+ "Handle server request workspace/applyEdit"
(condition-case err
(progn
(eglot--apply-workspace-edit edit 'confirm)
@@ -1127,26 +1125,27 @@ Records START, END and PRE-CHANGE-LENGTH locally."
(defun eglot--signal-textDocument/didOpen ()
"Send textDocument/didOpen to server."
(setq eglot--recent-changes (cons [] []))
- (eglot--notify (eglot--current-process-or-lose)
- :textDocument/didOpen
- (eglot--obj :textDocument
- (eglot--TextDocumentItem))))
+ (eglot--notify
+ (eglot--current-process-or-lose)
+ :textDocument/didOpen `(:textDocument ,(eglot--TextDocumentItem))))
(defun eglot--signal-textDocument/didClose ()
"Send textDocument/didClose to server."
- (eglot--notify (eglot--current-process-or-lose)
- :textDocument/didClose
- (eglot--obj :textDocument
- (eglot--TextDocumentIdentifier))))
+ (eglot--notify
+ (eglot--current-process-or-lose)
+ :textDocument/didClose `(:textDocument ,(eglot--TextDocumentIdentifier))))
(defun eglot--signal-textDocument/willSave ()
"Send textDocument/willSave to server."
- (eglot--notify
- (eglot--current-process-or-lose)
- :textDocument/willSave
- (eglot--obj
- :reason 1 ; Manual, emacs laughs in the face of auto-save muahahahaha
- :textDocument (eglot--TextDocumentIdentifier))))
+ (let ((proc (eglot--current-process-or-lose))
+ (params `(:reason 1 :textDocument ,(eglot--TextDocumentIdentifier))))
+ (eglot--notify proc :textDocument/willSave params)
+ (ignore-errors
+ (let ((eglot-request-timeout 0.5))
+ (when (plist-get :willSaveWaitUntil
+ (eglot--server-capable :textDocumentSync))
+ (eglot--apply-text-edits
+ (eglot--request proc :textDocument/willSaveWaituntil params)))))))
(defun eglot--signal-textDocument/didSave ()
"Send textDocument/didSave to server."
@@ -1426,22 +1425,20 @@ If SKIP-SIGNATURE, don't try to send
textDocument/signatureHelp."
entries))
(funcall oldfun)))
-(defun eglot--apply-text-edits (buffer edits &optional version)
- "Apply the EDITS for BUFFER."
- (with-current-buffer buffer
- (unless (or (not version)
- (equal version eglot--versioned-identifier))
- (eglot--error "Edits on `%s' require version %d, you have %d"
- buffer version eglot--versioned-identifier))
- (eglot--mapply
- (eglot--lambda (&key range newText)
- (save-restriction
- (widen)
- (save-excursion
- (eglot--with-lsp-range (beg end) range
- (goto-char beg) (delete-region beg end) (insert newText)))))
- edits)
- (eglot--message "%s: Performed %s edits" (current-buffer) (length edits))))
+(defun eglot--apply-text-edits (edits &optional version)
+ "Apply EDITS for current buffer if at VERSION, or if it's nil."
+ (unless (or (not version) (equal version eglot--versioned-identifier))
+ (eglot--error "Edits on `%s' require version %d, you have %d"
+ (current-buffer) version eglot--versioned-identifier))
+ (eglot--mapply
+ (eglot--lambda (&key range newText)
+ (save-restriction
+ (widen)
+ (save-excursion
+ (eglot--with-lsp-range (beg end) range
+ (goto-char beg) (delete-region beg end) (insert newText)))))
+ edits)
+ (eglot--message "%s: Performed %s edits" (current-buffer) (length edits)))
(defun eglot--apply-workspace-edit (wedit &optional confirm)
"Apply the workspace edit WEDIT. If CONFIRM, ask user first."
@@ -1471,9 +1468,8 @@ Proceed? "
(let (edit)
(while (setq edit (car prepared))
(cl-destructuring-bind (path edits &optional version) edit
- (eglot--apply-text-edits (find-file-noselect path)
- edits
- version)
+ (with-current-buffer (find-file-noselect path)
+ (eglot--apply-text-edits edits version))
(pop prepared))))
(if prepared
(eglot--warn "Caution: edits of files %s failed."
- [elpa] externals/eglot f89f859 114/139: Simplify mode-line updating logic, (continued)
- [elpa] externals/eglot f89f859 114/139: Simplify mode-line updating logic, Jo�o T�vora, 2018/05/14
- [elpa] externals/eglot 3a6c637 099/139: Support textDocument/rename, Jo�o T�vora, 2018/05/14
- [elpa] externals/eglot 581608f 115/139: Resist server failure during synchronous requests, Jo�o T�vora, 2018/05/14
- [elpa] externals/eglot 56cf02d 126/139: Rework autoreconnection logic, Jo�o T�vora, 2018/05/14
- [elpa] externals/eglot 4c0bfc3 139/139: Support didChangeWatchedFiles with dynamic registration, Jo�o T�vora, 2018/05/14
- [elpa] externals/eglot 42177d0 107/139: New "deferred requests" that wait until server is ready, Jo�o T�vora, 2018/05/14
- [elpa] externals/eglot 29f6b4c 129/139: Tweak README.md, Jo�o T�vora, 2018/05/14
- [elpa] externals/eglot 1fb2bcb 132/139: Ask server for textDocument/signatureHelp if it supports it, Jo�o T�vora, 2018/05/14
- [elpa] externals/eglot e63dad0 092/139: Simplify mode-line code with a helper., Jo�o T�vora, 2018/05/14
- [elpa] externals/eglot ab575d2 120/139: Rename functions. eglot--request is now the synchronous one, Jo�o T�vora, 2018/05/14
- [elpa] externals/eglot 41f5922 137/139: Now send willSaveWaitUntil,
Jo�o T�vora <=
- [elpa] externals/eglot 458bc69 110/139: More correctly setup rust-mode-related autoloads, Jo�o T�vora, 2018/05/14
- [elpa] externals/eglot 9af84a2 124/139: Prepare to sumbit to GNU ELPA, Jo�o T�vora, 2018/05/14
- [elpa] externals/eglot 0625b6c 123/139: (eglot--xref-make): Fix Use of cl-destructuring-bind., Jo�o T�vora, 2018/05/14
- [elpa] externals/eglot 589e1ea 138/139: Remove an unused variable, Jo�o T�vora, 2018/05/14
- [elpa] externals/eglot 49fb02f 135/139: Use RLS in Travis CI and add actual tests, Jo�o T�vora, 2018/05/14
- [elpa] externals/eglot dc08e8e 134/139: Fix automatic project creation, Jo�o T�vora, 2018/05/14
- [elpa] externals/eglot e964abe 091/139: Get rid of eglot--buffer-open-count, Jo�o T�vora, 2018/05/14
- [elpa] externals/eglot c7b9002 116/139: Only call deferred actions after a full message has been received, Jo�o T�vora, 2018/05/14
- [elpa] externals/eglot 418412b 131/139: Fix copyright header. Obviously not since 2003, Jo�o T�vora, 2018/05/14
- [elpa] externals/eglot 714e5be 086/139: Half-baked textDocument/hover support, Jo�o T�vora, 2018/05/14