[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/eglot 3f6d2e2 04/15: Close #4: Collect regions to chang
From: |
João Távora |
Subject: |
[elpa] externals/eglot 3f6d2e2 04/15: Close #4: Collect regions to change as markers, then edit |
Date: |
Sun, 20 May 2018 19:59:02 -0400 (EDT) |
branch: externals/eglot
commit 3f6d2e226577a5f93fcbf8bed0728ffd3cb0613a
Author: João Távora <address@hidden>
Commit: João Távora <address@hidden>
Close #4: Collect regions to change as markers, then edit
* eglot.el (eglot--lsp-position-to-point): Accept MARKER optional
arg.
(eglot--range-region): Accept MARKERS optional arg. Return a list.
(eglot--server-textDocument/publishDiagnostics)
(eglot--hover-info, eglot-eldoc-function): eglot--range-region
returns a list, not a cons.
(eglot--apply-text-edits): First collect regions as markers, then
edit.
---
eglot.el | 37 ++++++++++++++++++++-----------------
1 file changed, 20 insertions(+), 17 deletions(-)
diff --git a/eglot.el b/eglot.el
index 9810290..3635e47 100644
--- a/eglot.el
+++ b/eglot.el
@@ -748,15 +748,16 @@ DEFERRED is passed to `eglot--async-request', which see."
(- (goto-char (or pos (point)))
(line-beginning-position)))))
-(defun eglot--lsp-position-to-point (pos-plist)
- "Convert LSP position POS-PLIST to Emacs point."
+(defun eglot--lsp-position-to-point (pos-plist &optional marker)
+ "Convert LSP position POS-PLIST to Emacs point.
+If optional MARKER, return a marker instead"
(save-excursion (goto-char (point-min))
(forward-line (plist-get pos-plist :line))
(forward-char
(min (plist-get pos-plist :character)
(- (line-end-position)
(line-beginning-position))))
- (point)))
+ (if marker (copy-marker (point-marker)) (point))))
(defun eglot--path-to-uri (path)
"URIfy PATH."
@@ -798,10 +799,11 @@ DEFERRED is passed to `eglot--async-request', which see."
"Determine if current server is capable of FEAT."
(plist-get (eglot--capabilities (eglot--current-process-or-lose)) feat))
-(defun eglot--range-region (range)
- "Return region (BEG . END) that represents LSP RANGE."
- (cons (eglot--lsp-position-to-point (plist-get range :start))
- (eglot--lsp-position-to-point (plist-get range :end))))
+(defun eglot--range-region (range &optional markers)
+ "Return region (BEG END) that represents LSP RANGE.
+If optional MARKERS, make markers."
+ (list (eglot--lsp-position-to-point (plist-get range :start) markers)
+ (eglot--lsp-position-to-point (plist-get range :end) markers)))
;;; Minor modes
@@ -998,7 +1000,7 @@ function with the server still running."
collect (cl-destructuring-bind (&key range severity _group
_code source message)
diag-spec
- (pcase-let ((`(,beg . ,end) (eglot--range-region range)))
+ (pcase-let ((`(,beg ,end) (eglot--range-region range)))
(flymake-make-diagnostic (current-buffer)
beg end
(cond ((<= severity 1) :error)
@@ -1333,7 +1335,7 @@ DUMMY is ignored"
(defun eglot--hover-info (contents &optional range)
(concat (and range
- (pcase-let ((`(,beg . ,end) (eglot--range-region range)))
+ (pcase-let ((`(,beg ,end) (eglot--range-region range)))
(concat (buffer-substring beg end) ": ")))
(mapconcat #'eglot--format-markup
(append
@@ -1413,7 +1415,7 @@ If SKIP-SIGNATURE, don't try to send
textDocument/signatureHelp."
(setq eglot--highlights
(when-buffer-window
(mapcar (eglot--lambda (&key range _kind)
- (pcase-let ((`(,beg . ,end)
+ (pcase-let ((`(,beg ,end)
(eglot--range-region
range)))
(let ((ov (make-overlay beg end)))
(overlay-put ov 'face 'highlight)
@@ -1447,13 +1449,14 @@ If SKIP-SIGNATURE, don't try to send
textDocument/signatureHelp."
(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))
- (mapc (eglot--lambda (&key range newText)
- (save-restriction
- (widen)
- (save-excursion
- (pcase-let ((`(,beg . ,end) (eglot--range-region range)))
- (goto-char beg) (delete-region beg end) (insert newText)))))
- edits)
+ (save-restriction
+ (widen)
+ (save-excursion
+ (mapc (eglot--lambda (newText beg end)
+ (goto-char beg) (delete-region beg end) (insert newText))
+ (mapcar (eglot--lambda (&key range newText)
+ (cons newText (eglot--range-region range 'markers)))
+ edits))))
(eglot--message "%s: Performed %s edits" (current-buffer) (length edits)))
(defun eglot--apply-workspace-edit (wedit &optional confirm)
- [elpa] externals/eglot updated (8e5acb1 -> 24877ae), João Távora, 2018/05/20
- [elpa] externals/eglot c648c4f 08/15: Robustness fixes for the request mechanism, João Távora, 2018/05/20
- [elpa] externals/eglot 3f6d2e2 04/15: Close #4: Collect regions to change as markers, then edit,
João Távora <=
- [elpa] externals/eglot a91d72c 01/15: Simplify some infrastructure fucntions, João Távora, 2018/05/20
- [elpa] externals/eglot 258fb98 12/15: Travis now runs python-language-server tests, João Távora, 2018/05/20
- [elpa] externals/eglot 99686a9 11/15: * eglot.el (Version): Bump to 0.4, João Távora, 2018/05/20
- [elpa] externals/eglot 6894ed7 13/15: Tweak tests, hopefully stabilize pyls tests on Travis, João Távora, 2018/05/20
- [elpa] externals/eglot 4b9f4da 03/15: If we're going to send rootPath, better send an absolute one, João Távora, 2018/05/20
- [elpa] externals/eglot 2ede684 06/15: Better decide what text exactly to present as completions, João Távora, 2018/05/20
- [elpa] externals/eglot 17b7740 05/15: * eglot.el (eglot-clear-status): Remember to update modeline, João Távora, 2018/05/20
- [elpa] externals/eglot b45cb80 02/15: Robustify timer handling for eglot--async-request, João Távora, 2018/05/20
- [elpa] externals/eglot ace6fce 07/15: Check capabilities before sending :completionItem/resolve, João Távora, 2018/05/20
- [elpa] externals/eglot 24877ae 15/15: Fix a bug introduced in the previous commit, João Távora, 2018/05/20