Skip to content

Commit 34de304

Browse files
authored
Centralize SymbolInformation rendering (#2310)
* Centralize SymbolInformation rendering In various different parts of `lsp', where SymbolInformation has to be rendered (lsp-ivy, lsp-treemacs, lsp-imenu), only the :name is shown as a string. This is insufficient, as other information is then ignore displayed (currently only :deprecated?). Add a function, `lsp-render-symbol-information', which behaves similar to `lsp-render-symbol'. Use it in `lsp--imenu-create-non-hierarchical' index. * Check for an empty containerName
1 parent a9c5fec commit 34de304

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

lsp-mode.el

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6210,17 +6210,27 @@ the signature)."
62106210
(propertize name 'face 'lsp-face-semhl-deprecated) name)))
62116211
(concat name detail)))
62126212

6213-
(lsp-defun lsp--symbol-to-imenu-elem ((sym &as &SymbolInformation :name :container-name?))
6213+
(lsp-defun lsp-render-symbol-information ((&SymbolInformation :name :deprecated? :container-name?)
6214+
separator)
6215+
"Render a piece of SymbolInformation.
6216+
Handle :deprecated?. If SEPARATOR is non-nil, the
6217+
symbol's (optional) parent, SEPARATOR and the symbol itself are
6218+
concatenated."
6219+
(when (and separator container-name? (not (string-empty-p container-name?)))
6220+
(setq name (concat name separator container-name?)))
6221+
(if deprecated? (propertize name 'face 'lsp-face-semhl-deprecated) name))
6222+
6223+
(defun lsp--symbol-to-imenu-elem (sym)
62146224
"Convert SYM to imenu element.
62156225
62166226
SYM is a SymbolInformation message.
62176227
62186228
Return a cons cell (full-name . start-point)."
62196229
(let ((start-point (ht-get lsp--line-col-to-point-hash-table
62206230
(lsp--get-line-and-col sym))))
6221-
(cons (if (and lsp-imenu-show-container-name container-name?)
6222-
(concat container-name? lsp-imenu-container-name-separator name)
6223-
name)
6231+
(cons (lsp-render-symbol-information
6232+
sym (and lsp-imenu-show-container-name
6233+
lsp-imenu-container-name-separator))
62246234
start-point)))
62256235

62266236
(lsp-defun lsp--symbol-to-hierarchical-imenu-elem ((sym &as &DocumentSymbol :children?))

0 commit comments

Comments
 (0)