[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
feature/eglot2emacs 41a42e631b 096/120: Don't return poorly supported "s
From: |
João Távora |
Subject: |
feature/eglot2emacs 41a42e631b 096/120: Don't return poorly supported "special elements" in eglot-imenu |
Date: |
Thu, 20 Oct 2022 07:17:06 -0400 (EDT) |
branch: feature/eglot2emacs
commit 41a42e631bd798151130097feafa6f535161b9de
Author: João Távora <joaotavora@gmail.com>
Commit: João Távora <joaotavora@gmail.com>
Don't return poorly supported "special elements" in eglot-imenu
Fix https://github.com/joaotavora/eglot/issues/758,
https://github.com/joaotavora/eglot/issues/536,
https://github.com/joaotavora/eglot/issues/535.
Eglot's eglot-imenu returned a structure compliant with the rules
outlined in imenu--index-alist. In particular, it returned some
elements of the form
(INDEX-NAME POSITION GOTO-FN ARGUMENTS...)
The original intention (mine) must have been to allow fancy
highlighting of the position navigated to with a custom GOTO-FN.
Not only was access to that fanciness never implemented, but many
other imenu frontends do not support such elements.
See for example https://github.com/joaotavora/eglot/issues/758,
https://github.com/joaotavora/eglot/issues/536,
https://github.com/joaotavora/eglot/issues/535. And also related issues in
other
packages:
https://github.com/IvanMalison/flimenu/issues/6
https://github.com/bmag/imenu-list/issues/58
So it's best to remove this problematic feature for now. It can be
added back later.
* eglot.el (eglot-imenu): Simplify.
* NEWS.md: Mention change
---
lisp/progmodes/eglot.el | 52 ++++++++++++++++++++++++-------------------------
1 file changed, 25 insertions(+), 27 deletions(-)
diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index 8088490363..2ac9b0dff6 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -2916,39 +2916,37 @@ for which LSP on-type-formatting should be requested."
nil)))
(defun eglot-imenu ()
- "EGLOT's `imenu-create-index-function'."
+ "EGLOT's `imenu-create-index-function'.
+Returns a list as described in docstring of `imenu--index-alist'."
(cl-labels
- ((visit (_name one-obj-array)
- (imenu-default-goto-function
- nil (car (eglot--range-region
- (eglot--dcase (aref one-obj-array 0)
- (((SymbolInformation) location)
- (plist-get location :range))
- (((DocumentSymbol) selectionRange)
- selectionRange))))))
- (unfurl (obj)
- (eglot--dcase obj
- (((SymbolInformation)) (list obj))
- (((DocumentSymbol) name children)
- (cons obj
- (mapcar
- (lambda (c)
- (plist-put
- c :containerName
- (let ((existing (plist-get c :containerName)))
- (if existing (format "%s::%s" name existing)
- name))))
- (mapcan #'unfurl children)))))))
+ ((unfurl (obj)
+ (eglot--dcase obj
+ (((SymbolInformation)) (list obj))
+ (((DocumentSymbol) name children)
+ (cons obj
+ (mapcar
+ (lambda (c)
+ (plist-put
+ c :containerName
+ (let ((existing (plist-get c :containerName)))
+ (if existing (format "%s::%s" name existing)
+ name))))
+ (mapcan #'unfurl children)))))))
(mapcar
(pcase-lambda (`(,kind . ,objs))
(cons
(alist-get kind eglot--symbol-kind-names "Unknown")
(mapcan (pcase-lambda (`(,container . ,objs))
- (let ((elems (mapcar (lambda (obj)
- (list (plist-get obj :name)
- `[,obj] ;; trick
- #'visit))
- objs)))
+ (let ((elems (mapcar
+ (lambda (obj)
+ (cons (plist-get obj :name)
+ (car (eglot--range-region
+ (eglot--dcase obj
+ (((SymbolInformation) location)
+ (plist-get location :range))
+ (((DocumentSymbol)
selectionRange)
+ selectionRange))))))
+ objs)))
(if container (list (cons container elems)) elems)))
(seq-group-by
(lambda (e) (plist-get e :containerName)) objs))))
- feature/eglot2emacs 5b62d0071e 040/120: Enable lsp project-wide diagnostics via flymake, (continued)
- feature/eglot2emacs 5b62d0071e 040/120: Enable lsp project-wide diagnostics via flymake, João Távora, 2022/10/20
- feature/eglot2emacs 5d2f6bc667 055/120: Map more emacs variables to lsp formattingoptions fields, João Távora, 2022/10/20
- feature/eglot2emacs c06860b0f4 022/120: Bump eglot version to 1.8, João Távora, 2022/10/20
- feature/eglot2emacs 97ded82277 033/120: ; * eglot.el: move obsolete definition to new section., João Távora, 2022/10/20
- feature/eglot2emacs a905bad633 024/120: * eglot.el: improve commentary section., João Távora, 2022/10/20
- feature/eglot2emacs f550342059 069/120: Add out-of-box support for purescript lsp server, João Távora, 2022/10/20
- feature/eglot2emacs f8344871a0 075/120: Update docstring of eglot-events-buffer-size, João Távora, 2022/10/20
- feature/eglot2emacs e72fa6d867 082/120: Experiment with grouping in xref-backend-identifier-completion-table, João Távora, 2022/10/20
- feature/eglot2emacs fd5a5f16d7 081/120: Make c-u m-. work half decently, João Távora, 2022/10/20
- feature/eglot2emacs 6c8aee268d 079/120: Prevent desktop.el from saving/restoring eglot--managed-mode, João Távora, 2022/10/20
- feature/eglot2emacs 41a42e631b 096/120: Don't return poorly supported "special elements" in eglot-imenu,
João Távora <=
- feature/eglot2emacs f06a837f29 109/120: Shoosh byte-compilation warnings about line numbering functions, João Távora, 2022/10/20
- feature/eglot2emacs 806734c1b1 119/120: Expose eglot-{} to be used in eglot-workspace-configuration, João Távora, 2022/10/20
- feature/eglot2emacs 426d97f172 001/120: ; prefer https to http addresses, João Távora, 2022/10/20
- feature/eglot2emacs fb8706165c 004/120: Use fortls also for fortran-mode, João Távora, 2022/10/20
- feature/eglot2emacs a218f52ec9 012/120: Un-reverse references in xref buffer, João Távora, 2022/10/20
- feature/eglot2emacs be1e214fb2 013/120: Add cmake-language-server for cmake-mode, João Távora, 2022/10/20
- feature/eglot2emacs 512d8b9f59 011/120: Add variable to withhold the init req process id, João Távora, 2022/10/20
- feature/eglot2emacs 09c071d3d1 019/120: Add tooltip describing pending requests, João Távora, 2022/10/20
- feature/eglot2emacs f0b9018f52 018/120: Properly print error message of eglot-alternatives, João Távora, 2022/10/20
- feature/eglot2emacs ae7315b5f1 016/120: ; fix license statement, João Távora, 2022/10/20