Skip to content

Commit 452b7bd

Browse files
authored
`lsp-render-symbol': check if :detail? is empty (#2312)
* `lsp-render-symbol': check if :detail? is empty Some language servers apparently send an empty detail? field, causing strange output. * `lsp-render-symbol': render :detail? like VSCode :detail? no longer replaces :name. If present, and show-detail? is specified, it is now rendered after a colon. * Address review: use `s-present?' * `lsp-render-symbol': remove colon * `lsp-render-symbol': trim :detail? JDTLS specifies :detail?s of the form " : <type>", which would cause awkward double spacing. Trim :detail? on the left before rendering. * `lsp-render-symbol': use a new face instead * Add `lsp-details-face' Add a new face, `lsp-details-face', which shall be the base for various auxiliary information displays. Use it as the default for `lsp-signature-face' and `lsp-lens-face'. * Add missing :group to `lsp-details-face'
1 parent 3620cda commit 452b7bd

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

lsp-lens.el

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
:group 'lsp-faces)
3535

3636
(defface lsp-lens-face
37-
'((t :height 0.8 :inherit shadow))
37+
'((t :inherit lsp-details-face))
3838
"The face used for code lens overlays."
3939
:group 'lsp-faces)
4040

lsp-mode.el

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

6193+
(defface lsp-details-face '((t :height 0.8 :inherit shadow))
6194+
"Used to display additional information troughout `lsp'.
6195+
Things like line numbers, signatures, ... are considered
6196+
additional information. Often, additional faces are defined that
6197+
inherit from this face by default, like `lsp-signature-face', and
6198+
they may be customized for finer control."
6199+
:group 'lsp-faces)
6200+
6201+
(defface lsp-signature-face '((t :inherit lsp-details-face))
6202+
"Used to display signatures in `imenu', ...."
6203+
:group 'lsp-faces)
6204+
61936205
(lsp-defun lsp-render-symbol ((&DocumentSymbol :name :detail? :deprecated?)
61946206
show-detail?)
61956207
"Render INPUT0, an `&DocumentSymbol', to a string.
61966208
If SHOW-DETAIL? is set, make use of its `:detail?' field (often
61976209
the signature)."
6198-
(let ((base (or (and show-detail? detail?) detail? name)))
6199-
(if deprecated? (propertize base 'face 'lsp-face-semhl-deprecated)
6200-
base)))
6210+
(let ((detail (and show-detail? (s-present? detail?)
6211+
(propertize (concat " " (s-trim-left detail?))
6212+
'face 'lsp-signature-face)))
6213+
(name (if deprecated?
6214+
(propertize name 'face 'lsp-face-semhl-deprecated) name)))
6215+
(concat name detail)))
62016216

62026217
(lsp-defun lsp--symbol-to-imenu-elem ((sym &as &SymbolInformation :name :container-name?))
62036218
"Convert SYM to imenu element.

0 commit comments

Comments
 (0)