[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/eglot 444a8c3 16/26: Per #173: robustify previous fix a
From: |
João Távora |
Subject: |
[elpa] externals/eglot 444a8c3 16/26: Per #173: robustify previous fix against non-standard insertion bindings |
Date: |
Sun, 9 Dec 2018 19:11:28 -0500 (EST) |
branch: externals/eglot
commit 444a8c3b3ec29eceeda26b72493a60c44a9bd951
Author: João Távora <address@hidden>
Commit: João Távora <address@hidden>
Per #173: robustify previous fix against non-standard insertion bindings
* eglot.el (eglot--managed-mode): Manage post-self-insert-hook.
(eglot--last-inserted-char): New variable.
(eglot--post-self-insert-hook): Set it.
(eglot--before-change): Reset it.
(eglot--CompletionParams): Use it.
---
eglot.el | 27 +++++++++++++++++++--------
1 file changed, 19 insertions(+), 8 deletions(-)
diff --git a/eglot.el b/eglot.el
index 86db5ea..e4547c5 100644
--- a/eglot.el
+++ b/eglot.el
@@ -1052,6 +1052,7 @@ and just return it. PROMPT shouldn't end with a question
mark."
(add-hook 'xref-backend-functions 'eglot-xref-backend nil t)
(add-hook 'completion-at-point-functions #'eglot-completion-at-point nil t)
(add-hook 'change-major-mode-hook 'eglot--managed-mode-onoff nil t)
+ (add-hook 'post-self-insert-hook 'eglot--post-self-insert-hook nil t)
(add-function :before-until (local 'eldoc-documentation-function)
#'eglot-eldoc-function)
(add-function :around (local 'imenu-create-index-function) #'eglot-imenu)
@@ -1068,6 +1069,7 @@ and just return it. PROMPT shouldn't end with a question
mark."
(remove-hook 'xref-backend-functions 'eglot-xref-backend t)
(remove-hook 'completion-at-point-functions #'eglot-completion-at-point t)
(remove-hook 'change-major-mode-hook #'eglot--managed-mode-onoff t)
+ (remove-hook 'post-self-insert-hook 'eglot--post-self-insert-hook t)
(remove-function (local 'eldoc-documentation-function)
#'eglot-eldoc-function)
(remove-function (local 'imenu-create-index-function) #'eglot-imenu)
@@ -1383,12 +1385,18 @@ THINGS are either registrations or unregisterations."
(list :textDocument (eglot--TextDocumentIdentifier)
:position (eglot--pos-to-lsp-position)))
+(defvar-local eglot--last-inserted-char nil
+ "If non-nil, value of the last inserted character in buffer.")
+
+(defun eglot--post-self-insert-hook ()
+ "Set `eglot--last-inserted-char.'"
+ (setq eglot--last-inserted-char last-input-event))
+
(defun eglot--CompletionParams ()
(append
(eglot--TextDocumentPositionParams)
`(:context
- ,(if-let (trigger (and (eq last-command 'self-insert-command)
- (characterp last-input-event)
+ ,(if-let (trigger (and (characterp eglot--last-inserted-char)
(cl-find last-input-event
(eglot--server-capable :completionProvider
:triggerCharacters)
@@ -1406,15 +1414,18 @@ THINGS are either registrations or unregisterations."
(defvar-local eglot--change-idle-timer nil "Idle timer for didChange signals.")
(defun eglot--before-change (start end)
- "Hook onto `before-change-functions'.
-Records START and END, crucially convert them into
-LSP (line/char) positions before that information is
-lost (because the after-change thingy doesn't know if newlines
-were deleted/added)"
+ "Hook onto `before-change-functions'."
+ ;; Records START and END, crucially convert them into LSP
+ ;; (line/char) positions before that information is lost (because
+ ;; the after-change thingy doesn't know if newlines were
+ ;; deleted/added)
(when (listp eglot--recent-changes)
(push `(,(eglot--pos-to-lsp-position start)
,(eglot--pos-to-lsp-position end))
- eglot--recent-changes)))
+ eglot--recent-changes))
+ ;; Also, reset `eglot--last-inserted-char' which might be set later
+ ;; by `eglot--post-self-insert-hook'.
+ (setq eglot--last-inserted-char nil))
(defun eglot--after-change (start end pre-change-length)
"Hook onto `after-change-functions'.
- [elpa] externals/eglot 5bbf884 11/26: Use eglot--dbind for destructuring, (continued)
- [elpa] externals/eglot 5bbf884 11/26: Use eglot--dbind for destructuring, João Távora, 2018/12/09
- [elpa] externals/eglot 81d035f 04/26: Fix #52: Use entire line as xref summary when available, João Távora, 2018/12/09
- [elpa] externals/eglot 96169d8 18/26: Per #173: fix bug introduced by previous fix, João Távora, 2018/12/09
- [elpa] externals/eglot 4874c22 14/26: Use javascript-typescript-langserver for typescript-mode (#174), João Távora, 2018/12/09
- [elpa] externals/eglot 66a1704 22/26: Scratch/use elpa flymake (#178), João Távora, 2018/12/09
- [elpa] externals/eglot f63bedb 20/26: Fix #144: Use eglot--dbind and eglot--lambda throughout, João Távora, 2018/12/09
- [elpa] externals/eglot 3922cf3 01/26: Per #144, #156: control strictness towards incoming LSP messages, João Távora, 2018/12/09
- [elpa] externals/eglot 8140be5 07/26: Touch up last commit, João Távora, 2018/12/09
- [elpa] externals/eglot 95ef9e1 08/26: Robustify tests against (M)ELPA eglot installations, João Távora, 2018/12/09
- [elpa] externals/eglot 38da3d3 15/26: Fix #159: Properly clear old diagnostics when making new ones, João Távora, 2018/12/09
- [elpa] externals/eglot 444a8c3 16/26: Per #173: robustify previous fix against non-standard insertion bindings,
João Távora <=
- [elpa] externals/eglot 1d42be4 13/26: Close #173: support completionContext to help servers like ccls, João Távora, 2018/12/09
- [elpa] externals/eglot e2200ce 09/26: Simplify interface of eglot--dbind macro, João Távora, 2018/12/09
- [elpa] externals/eglot c1848c3 23/26: Handle array params to server notification or requests, João Távora, 2018/12/09
- [elpa] externals/eglot 23accee 26/26: * eglot.el (Version): Bump to 1.3, João Távora, 2018/12/09
- [elpa] externals/eglot 37706af 21/26: Warn about suspicious interface usage at compile-time, João Távora, 2018/12/09
- [elpa] externals/eglot 6de3d9c 10/26: Per #171, #156: Introduce eglot--dcase, João Távora, 2018/12/09
- [elpa] externals/eglot a46f003 17/26: Fix #164: handle CodeAction/Command polymorphism with eglot--dcase, João Távora, 2018/12/09
- [elpa] externals/eglot 6b0b1b7 24/26: Be lenient by default to unknown methods or notifications, João Távora, 2018/12/09
- [elpa] externals/eglot 973cd81 25/26: Close #180: Add preamble to comparison to lsp-mode.el, João Távora, 2018/12/09
- [elpa] externals/eglot a1f2033 12/26: Fix #116, #150: don't break in indirect buffers, João Távora, 2018/12/09