@@ -67,17 +67,11 @@ ignored."
67
67
:group 'lsp-completion
68
68
:package-version '(lsp-mode . " 7.0.1" ))
69
69
70
- (defcustom lsp-completion-show-detail t
70
+ (defcustom lsp-completion-show-detail nil
71
71
" Whether or not to show detail of completion candidates."
72
72
:type 'boolean
73
73
:group 'lsp-completion )
74
74
75
- (defcustom lsp-completion-show-label-description t
76
- " Whether or not to show description of completion candidates."
77
- :type 'boolean
78
- :group 'lsp-completion
79
- :package-version '(lsp-mode . " 9.0.0" ))
80
-
81
75
(defcustom lsp-completion-no-cache nil
82
76
" Whether or not caching the returned completions from server."
83
77
:type 'boolean
@@ -246,24 +240,41 @@ The CLEANUP-FN will be called to cleanup."
246
240
(funcall callback completion-item)
247
241
(when cleanup-fn (funcall cleanup-fn))))))
248
242
249
- (defun lsp-completion--get-label-detail (item )
243
+ (defun lsp-completion--get-label-detail (item &optional omit-description )
250
244
" Construct label detail from completion item ITEM."
251
- (-let (((completion-item &as &CompletionItem :detail? :kind? :label-details? )
252
- item))
253
- (concat (when (and lsp-completion-show-detail detail?)
254
- (concat " " (s-replace " \r " " " detail?) ))
255
- (when (and lsp-completion-show-label-description label-details?)
256
- (when-let* ((description (and label-details? (lsp:label-details-description label-details?) )))
257
- (format " %s " description)))
258
- (when lsp-completion-show-kind
259
- (when-let* ((kind-name (and kind? (aref lsp-completion--item-kind kind?) )))
260
- (format " (%s ) " kind-name))))))
245
+ (-let (((&CompletionItem :detail? :label-details? ) item))
246
+ (cond ((and label-details?
247
+ (or (lsp:label-details-detail? label-details?)
248
+ (lsp:label-details-description? label-details?) ))
249
+ (-let (((&LabelDetails :detail? :description? ) label-details?) )
250
+ (concat
251
+ (unless (and lsp-completion-show-detail
252
+ detail?
253
+ (string-prefix-p " " detail?) )
254
+ " " )
255
+ (when lsp-completion-show-detail
256
+ (s-replace " \r " " " detail?) )
257
+ (unless (or omit-description
258
+ (and description? (string-prefix-p " " description?) ))
259
+ " " )
260
+ (unless omit-description
261
+ description?) )))
262
+ (lsp-completion-show-detail
263
+ (concat (unless (and detail? (string-prefix-p " " detail?) )
264
+ " " )
265
+ (s-replace " \r " " " detail?) )))))
261
266
262
267
(defun lsp-completion--annotate (cand )
263
268
" Annotation function for completion candidate CAND.
264
269
265
270
Returns unresolved completion item detail."
266
- (lsp-completion--get-label-detail (get-text-property 0 'lsp-completion-unresolved-item cand)))
271
+ (when-let ((lsp-completion-item (get-text-property 0 'lsp-completion-unresolved-item cand)))
272
+ (concat
273
+ (lsp-completion--get-label-detail lsp-completion-item)
274
+ (when lsp-completion-show-kind
275
+ (when-let* ((kind? (lsp:completion-item-kind? lsp-completion-item))
276
+ (kind-name (and kind? (aref lsp-completion--item-kind kind?) )))
277
+ (format " (%s ) " kind-name))))))
267
278
268
279
(defun lsp-completion--looking-back-trigger-characterp (trigger-characters )
269
280
" Return character if text before point match any of the TRIGGER-CHARACTERS."
@@ -467,7 +478,9 @@ The MARKERS and PREFIX value will be attached to each candidate."
467
478
468
479
Returns resolved completion item details."
469
480
(and (lsp-completion--resolve cand)
470
- (lsp-completion--get-label-detail (get-text-property 0 'lsp-completion-item cand))))
481
+ (lsp-completion--get-label-detail
482
+ (get-text-property 0 'lsp-completion-item cand)
483
+ t )))
471
484
472
485
(defun lsp-completion--get-documentation (item )
473
486
" Get doc comment for completion ITEM."
0 commit comments