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

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

[elpa] externals/eglot f74a80f 27/45: Make imenu hierarchical


From: João Távora
Subject: [elpa] externals/eglot f74a80f 27/45: Make imenu hierarchical
Date: Thu, 22 Nov 2018 19:15:31 -0500 (EST)

branch: externals/eglot
commit f74a80fd7138ab948fdb2bb0950cd31a7dba2fba
Author: Michał Krzywkowski <address@hidden>
Commit: mkcms <address@hidden>

    Make imenu hierarchical
    
    * eglot.el (eglot-imenu): Use :containerName to build a nested imenu
      index alist.
---
 eglot.el | 25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/eglot.el b/eglot.el
index f11a14e..22f509b 100644
--- a/eglot.el
+++ b/eglot.el
@@ -1670,20 +1670,29 @@ If SKIP-SIGNATURE, don't try to send 
textDocument/signatureHelp."
               (jsonrpc-lambda
                   (&key name kind location containerName _deprecated)
                 (cons (propertize
-                       (concat
-                        (and (stringp containerName)
-                             (not (string-empty-p containerName))
-                             (concat containerName "::"))
-                        name)
+                       name
                        :kind (alist-get kind eglot--symbol-kind-names
-                                        "(Unknown)"))
+                                        "Unknown")
+                       :containerName (and (stringp containerName)
+                                           (not (string-empty-p containerName))
+                                           containerName))
                       (eglot--lsp-position-to-point
                        (plist-get (plist-get location :range) :start))))
               (jsonrpc-request (eglot--current-server-or-lose)
                                :textDocument/documentSymbol
                                `(:textDocument 
,(eglot--TextDocumentIdentifier))))))
-        (seq-group-by (lambda (e) (get-text-property 0 :kind (car e)))
-                      entries))
+        (mapcar
+         (pcase-lambda (`(,kind . ,syms))
+           (let ((syms-by-scope (seq-group-by
+                                 (lambda (e)
+                                   (get-text-property 0 :containerName (car 
e)))
+                                 syms)))
+             (cons kind (cl-loop for (scope . elems) in syms-by-scope
+                                 append (if scope
+                                            (list (cons scope elems))
+                                          elems)))))
+         (seq-group-by (lambda (e) (get-text-property 0 :kind (car e)))
+                       entries)))
     (funcall oldfun)))
 
 (defun eglot--apply-text-edits (edits &optional version)



reply via email to

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