Skip to content

Commit 3620cda

Browse files
authored
Refactor/centralize document symbol rendering (#2307)
* Abstract away `&DocumentSymbol' rendering With microsoft/language-server-protocol#1130, the :detail? of DocumentSymbols might become more complex, causing lots of breakage. As such, abstracting away `&DocumentSymbol' rendering is needed. This needs to be a public API, as `lsp-treemacs' also renders DocumentSymbols. Bump the version because of that. * CHANGELOG: add new entry for `lsp-render-symbol' * Fix byte-compile warnings * Don't make a new release
1 parent 9d66f47 commit 3620cda

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

lsp-mode.el

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6190,6 +6190,15 @@ information, for example if it doesn't support DocumentSymbols."
61906190
:group 'lsp-imenu
61916191
:type 'boolean)
61926192

6193+
(lsp-defun lsp-render-symbol ((&DocumentSymbol :name :detail? :deprecated?)
6194+
show-detail?)
6195+
"Render INPUT0, an `&DocumentSymbol', to a string.
6196+
If SHOW-DETAIL? is set, make use of its `:detail?' field (often
6197+
the signature)."
6198+
(let ((base (or (and show-detail? detail?) detail? name)))
6199+
(if deprecated? (propertize base 'face 'lsp-face-semhl-deprecated)
6200+
base)))
6201+
61936202
(lsp-defun lsp--symbol-to-imenu-elem ((sym &as &SymbolInformation :name :container-name?))
61946203
"Convert SYM to imenu element.
61956204
@@ -6203,7 +6212,7 @@ Return a cons cell (full-name . start-point)."
62036212
name)
62046213
start-point)))
62056214

6206-
(lsp-defun lsp--symbol-to-hierarchical-imenu-elem ((sym &as &DocumentSymbol :name :detail? :children?))
6215+
(lsp-defun lsp--symbol-to-hierarchical-imenu-elem ((sym &as &DocumentSymbol :children?))
62076216
"Convert SYM to hierarchical imenu elements.
62086217
62096218
SYM is a DocumentSymbol message.
@@ -6215,7 +6224,7 @@ an alist
62156224
(\"symbol-name\" . ((\"(symbol-kind)\" . start-point)
62166225
cons-cells-from-children))"
62176226
(let ((filtered-children (lsp--imenu-filter-symbols children?))
6218-
(signature (or (and lsp-imenu-detailed-outline detail?) name)))
6227+
(signature (lsp-render-symbol sym lsp-imenu-detailed-outline)))
62196228
(if (seq-empty-p filtered-children)
62206229
(cons signature
62216230
(ht-get lsp--line-col-to-point-hash-table

0 commit comments

Comments
 (0)