Skip to content

Commit 067fa52

Browse files
authored
`lsp-imenu': show signatures (#2301)
1 parent 86d7e5d commit 067fa52

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

lsp-mode.el

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6182,6 +6182,13 @@ deserialization.")
61826182
(defvar-local lsp--line-col-to-point-hash-table nil
61836183
"Hash table with keys (line . col) and values that are either point positions or markers.")
61846184

6185+
(defcustom lsp-imenu-detailed-outline t
6186+
"Whether `lsp-imenu' should include signatures.
6187+
This will be ignored if the server doesn't provide the necessary
6188+
information, for example if it doesn't support DocumentSymbols."
6189+
:group 'lsp-imenu
6190+
:type 'boolean)
6191+
61856192
(lsp-defun lsp--symbol-to-imenu-elem ((sym &as &SymbolInformation :name :container-name?))
61866193
"Convert SYM to imenu element.
61876194

@@ -6195,7 +6202,7 @@ Return a cons cell (full-name . start-point)."
61956202
name)
61966203
start-point)))
61976204

6198-
(lsp-defun lsp--symbol-to-hierarchical-imenu-elem ((sym &as &DocumentSymbol :name :children?))
6205+
(lsp-defun lsp--symbol-to-hierarchical-imenu-elem ((sym &as &DocumentSymbol :name :detail? :children?))
61996206
"Convert SYM to hierarchical imenu elements.
62006207

62016208
SYM is a DocumentSymbol message.
@@ -6206,12 +6213,13 @@ an alist
62066213

62076214
(\"symbol-name\" . ((\"(symbol-kind)\" . start-point)
62086215
cons-cells-from-children))"
6209-
(let ((filtered-children (lsp--imenu-filter-symbols children?)))
6216+
(let ((filtered-children (lsp--imenu-filter-symbols children?))
6217+
(signature (or (and lsp-imenu-detailed-outline detail?) name)))
62106218
(if (seq-empty-p filtered-children)
6211-
(cons name
6219+
(cons signature
62126220
(ht-get lsp--line-col-to-point-hash-table
62136221
(lsp--get-line-and-col sym)))
6214-
(cons name
6222+
(cons signature
62156223
(lsp--imenu-create-hierarchical-index filtered-children)))))
62166224

62176225
(lsp-defun lsp--symbol-ignore ((&SymbolInformation :kind :location))

0 commit comments

Comments
 (0)