[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/elpa 41f5922 137/139: Now send willSaveWaitUntil
From: |
João Távora |
Subject: |
[elpa] externals/elpa 41f5922 137/139: Now send willSaveWaitUntil |
Date: |
Mon, 14 May 2018 09:53:51 -0400 (EDT) |
branch: externals/elpa
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/elpa af14364 093/139: Only request stuff that server says it's capable of, (continued)
- [elpa] externals/elpa af14364 093/139: Only request stuff that server says it's capable of, João Távora, 2018/05/14
- [elpa] externals/elpa d33a9b5 103/139: Simplify eglot--signal-textDocument/didChange, João Távora, 2018/05/14
- [elpa] externals/elpa 56c2e1d 104/139: Get rid of eglot-mode, João Távora, 2018/05/14
- [elpa] externals/elpa bbc64b4 087/139: Clean up client capabilities, João Távora, 2018/05/14
- [elpa] externals/elpa 23b79e0 111/139: Shorten summary line to appease package-lint.el, João Távora, 2018/05/14
- [elpa] externals/elpa 24466a9 096/139: When killing server, always wait 3 seconds, João Távora, 2018/05/14
- [elpa] externals/elpa 3a6c637 099/139: Support textDocument/rename, João Távora, 2018/05/14
- [elpa] externals/elpa 458bc69 110/139: More correctly setup rust-mode-related autoloads, João Távora, 2018/05/14
- [elpa] externals/elpa 3dcbc30 109/139: Add minimal headers, commentary and autoloads, João Távora, 2018/05/14
- [elpa] externals/elpa 581608f 115/139: Resist server failure during synchronous requests, João Távora, 2018/05/14
- [elpa] externals/elpa 41f5922 137/139: Now send willSaveWaitUntil,
João Távora <=
- [elpa] externals/elpa 05c67ee 112/139: Adjust flymake integration, João Távora, 2018/05/14
- [elpa] externals/elpa f89f859 114/139: Simplify mode-line updating logic, João Távora, 2018/05/14
- [elpa] externals/elpa 0625b6c 123/139: (eglot--xref-make): Fix Use of cl-destructuring-bind., João Távora, 2018/05/14
- [elpa] externals/elpa 56cf02d 126/139: Rework autoreconnection logic, João Távora, 2018/05/14
- [elpa] externals/elpa 49fb02f 135/139: Use RLS in Travis CI and add actual tests, João Távora, 2018/05/14
- [elpa] externals/elpa 29f58a6 127/139: Get rid of catch/loop/throw idiom (suggested by Thien-Thi Nguyen), João Távora, 2018/05/14
- [elpa] externals/elpa 418412b 131/139: Fix copyright header. Obviously not since 2003, João Távora, 2018/05/14
- [elpa] externals/elpa 54fc885 113/139: More RLS-specifics: update Flymake diags when indexing done, João Távora, 2018/05/14
- [elpa] externals/elpa 8a80fb7 105/139: Simplify `eglot-shutdown`, João Távora, 2018/05/14
- [elpa] externals/elpa d40f9ac 094/139: Half-decent imenu support via textDocument/documentSymbol, João Távora, 2018/05/14