summaryrefslogtreecommitdiff
path: root/lisp/progmodes
diff options
context:
space:
mode:
authorJoão Távora <joaotavora@gmail.com>2022-07-14 10:09:27 +0100
committerJoão Távora <joaotavora@gmail.com>2022-07-14 15:47:12 +0100
commitb59fa2548e5ec86c3f439fd59ad46abf8840a8ea (patch)
treef7ffadbcc0149ddff4d6c78076eeaf56975d050b /lisp/progmodes
parente72fa6d86764027d1c071b73cc83aef8d4d344de (diff)
downloademacs-b59fa2548e5ec86c3f439fd59ad46abf8840a8ea.tar.gz
emacs-b59fa2548e5ec86c3f439fd59ad46abf8840a8ea.tar.bz2
emacs-b59fa2548e5ec86c3f439fd59ad46abf8840a8ea.zip
Cosmetic decisions guaranteed to tick off someone somewhere (tm)
The symbols returned by the LSP server must be converted to unique strings if Emacs is to present them in a list. On the other hand, the search operates on the pattern and is completely controlled by the backend. There is not much Eglot, the LSP client, can do about this. Decided to present the unique string to the user, even though it could be hidden. All the manner of :annotation-function, :affixation-function, :group-funcion etc didn't seem to add much value. Grouping was especially useless, since it makes sense to respect the LSP server's account of sorting score, so that better results bubble up to the top. * eglot.el (xref-backend-identifier-completion-table): Uniquify symbols with containerName and kind. GitHub-reference: per https://github.com/joaotavora/eglot/issues/131
Diffstat (limited to 'lisp/progmodes')
-rw-r--r--lisp/progmodes/eglot.el55
1 files changed, 20 insertions, 35 deletions
diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index eccd67c1296..6d3667a84a9 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -2402,11 +2402,20 @@ Try to visit the target file for a richer summary line."
(cl-labels ((refresh (pat)
(mapcar
(lambda (wss)
- (eglot--dbind ((WorkspaceSymbol) name containerName) wss
+ (eglot--dbind
+ ((WorkspaceSymbol) name containerName kind) wss
(propertize
- (concat (and (not (zerop (length containerName)))
- (format "%s::" containerName))
- name)
+ (format "%s%s %s"
+ (if (zerop (length containerName)) ""
+ (concat (propertize containerName
+ 'face 'shadow)
+ " "))
+ name
+ (propertize (alist-get
+ kind
+ eglot--symbol-kind-names
+ "Unknown")
+ 'face 'shadow))
'eglot--lsp-workspaceSymbol wss)))
(with-current-buffer buf
(jsonrpc-request (eglot--current-server-or-lose)
@@ -2417,41 +2426,17 @@ Try to visit the target file for a richer summary line."
(probe (gethash pat cache :missing)))
(if (eq probe :missing) (puthash pat (refresh pat) cache)
probe)))
- (container (c)
- (plist-get (get-text-property
- 0 'eglot--lsp-workspaceSymbol c)
- :containerName)))
+ (score (c)
+ (cl-getf (get-text-property
+ 0 'eglot--lsp-workspaceSymbol c)
+ :score 0)))
(lambda (string _pred action)
(pcase action
(`metadata `(metadata
(cycle-sort-function
. ,(lambda (completions)
- (cl-sort completions
- #'string-lessp
- :key (lambda (c)
- (or (container c)
- "")))))
- (category . eglot-indirection-joy)
- ;; (annotation-function
- ;; . ,(lambda (c)
- ;; (plist-get (get-text-property
- ;; 0 'eglot--lsp-workspaceSymbol c)
- ;; :containerName)))
- ;; (affixation-function
- ;; . ,(lambda (comps)
- ;; (mapcar (lambda (c)
- ;; (list c
- ;; (plist-get (get-text-property
- ;; 0 'eglot--lsp-workspaceSymbol c)
- ;; :containerName)
- ;; " bla"))
- ;; comps)))
- (group-function
- . ,(lambda (c transformp)
- (if (not transformp)
- (container c)
- c)))
- ))
+ (cl-sort completions #'> :key #'score)))
+ (category . eglot-indirection-joy)))
(`(eglot--lsp-tryc . ,point) `(eglot--lsp-tryc . (,string . ,point)))
(`(eglot--lsp-allc . ,_point) `(eglot--lsp-allc . ,(lookup string)))
(_ nil)))))
@@ -2475,7 +2460,7 @@ Try to visit the target file for a richer summary line."
;; passed to LSP. The reason for this particular wording is to
;; construct a readable message "No references for LSP identifier at
;; point.". See https://github.com/joaotavora/eglot/issues/314
- "LSP identifier at point.")
+ "LSP identifier at point")
(defvar eglot--lsp-xref-refs nil
"`xref' objects for overriding `xref-backend-references''s.")