emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/eglot 2ede684 06/15: Better decide what text exactly to


From: João Távora
Subject: [elpa] externals/eglot 2ede684 06/15: Better decide what text exactly to present as completions
Date: Sun, 20 May 2018 19:59:02 -0400 (EDT)

branch: externals/eglot
commit 2ede68438087b8e829f1b815308b96c60e000b92
Author: João Távora <address@hidden>
Commit: João Távora <address@hidden>

    Better decide what text exactly to present as completions
    
    For inserting, :insertText takes precedence over :label.
    For annotating, first sentence of :documentation, then :detail,
    then :kind name.
    
    Also remember to send didChange in the :exit-function
    
    * eglot.el (eglot-completion-function): Rework main function and
    :annotation-function, and :exit-function
---
 eglot.el | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/eglot.el b/eglot.el
index 9d5ef80..e8af7ed 100644
--- a/eglot.el
+++ b/eglot.el
@@ -702,7 +702,7 @@ DEFERRED is passed to `eglot--async-request', which see."
                               (throw done `(error
                                             ,(format "Ooops: %s: %s" code 
message))))
                   :deferred deferred))
-                 (while t (accept-process-output nil 30)))
+                (while t (accept-process-output nil 30)))
             (when (cadr id-and-timer) (cancel-timer (cadr id-and-timer))))))
     (when (eq 'error (car res)) (eglot--error (cadr res)))
     (cadr res)))
@@ -1300,15 +1300,19 @@ DUMMY is ignored"
                                        :textDocument/completion))
                  (items (if (vectorp resp) resp (plist-get resp :items))))
             (mapcar
-             (eglot--lambda (&rest all &key label &allow-other-keys)
-               (add-text-properties 0 1 all label) label)
+             (eglot--lambda (&rest all &key label insertText &allow-other-keys)
+               (let ((insert (or insertText label)))
+                 (add-text-properties 0 1 all insert) insert))
              items))))
        :annotation-function
        (lambda (obj)
-         (propertize (concat " " (or (get-text-property 0 :detail obj)
-                                     (cdr (assoc (get-text-property 0 :kind 
obj)
-                                                 eglot--kind-names))))
-                     'face 'font-lock-function-name-face))
+         (cl-destructuring-bind (&key detail documentation kind 
&allow-other-keys)
+             (text-properties-at 0 obj)
+           (concat " " (propertize
+                        (or (and documentation
+                                 (replace-regexp-in-string "\n.*" "" 
documentation))
+                            detail (cdr (assoc kind eglot--kind-names)))
+                        'face 'font-lock-function-name-face))))
        :display-sort-function
        (lambda (items)
          (sort items (lambda (a b)
@@ -1329,8 +1333,9 @@ DUMMY is ignored"
                (font-lock-ensure)
                (insert documentation)
                (current-buffer)))))
-       :exit-function
-       (lambda (_string _status) (eglot-eldoc-function))))))
+       :exit-function (lambda (_string _status)
+                        (eglot--signal-textDocument/didChange)
+                        (eglot-eldoc-function))))))
 
 (defvar eglot--highlights nil "Overlays for textDocument/documentHighlight.")
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]