]> git.eshelyaron.com Git - emacs.git/commitdiff
Experiment with grouping in xref-backend-identifier-completion-table
authorJoão Távora <joaotavora@gmail.com>
Wed, 13 Jul 2022 15:42:10 +0000 (16:42 +0100)
committerJoão Távora <joaotavora@gmail.com>
Thu, 14 Jul 2022 14:47:12 +0000 (15:47 +0100)
Doesn't look very good.

* eglot.el (xref-backend-identifier-completion-table): Add stuff.

GitHub-reference: per https://github.com/joaotavora/eglot/issues/131

lisp/progmodes/eglot.el

index b17bfd1b5cd64c5b4b9b52cab9a083070943c608..eccd67c1296ec9a5cfbf035841703125cba5c161 100644 (file)
@@ -2416,12 +2416,42 @@ Try to visit the target file for a richer summary line."
                       (let* ((cache eglot--workspace-symbols-cache)
                              (probe (gethash pat cache :missing)))
                         (if (eq probe :missing) (puthash pat (refresh pat) cache)
-                          probe))))
+                          probe)))
+                    (container (c)
+                      (plist-get (get-text-property
+                                  0 'eglot--lsp-workspaceSymbol c)
+                                 :containerName)))
           (lambda (string _pred action)
             (pcase action
-              (`metadata '(metadata
-                           (display-sort-function . identity)
-                           (category . eglot-indirection-joy)))
+              (`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)))
+                           ))
               (`(eglot--lsp-tryc . ,point) `(eglot--lsp-tryc . (,string . ,point)))
               (`(eglot--lsp-allc . ,_point) `(eglot--lsp-allc . ,(lookup string)))
               (_ nil)))))