@@ -67,17 +67,11 @@ ignored."
6767 :group 'lsp-completion
6868 :package-version '(lsp-mode . " 7.0.1" ))
6969
70- (defcustom lsp-completion-show-detail t
70+ (defcustom lsp-completion-show-detail nil
7171 " Whether or not to show detail of completion candidates."
7272 :type 'boolean
7373 :group 'lsp-completion )
7474
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-
8175(defcustom lsp-completion-no-cache nil
8276 " Whether or not caching the returned completions from server."
8377 :type 'boolean
@@ -246,24 +240,41 @@ The CLEANUP-FN will be called to cleanup."
246240 (funcall callback completion-item)
247241 (when cleanup-fn (funcall cleanup-fn))))))
248242
249- (defun lsp-completion--get-label-detail (item )
243+ (defun lsp-completion--get-label-detail (item &optional omit-description )
250244 " 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?) )))))
261266
262267(defun lsp-completion--annotate (cand )
263268 " Annotation function for completion candidate CAND.
264269
265270Returns 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))))))
267278
268279(defun lsp-completion--looking-back-trigger-characterp (trigger-characters )
269280 " 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."
467478
468479Returns resolved completion item details."
469480 (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 )))
471484
472485(defun lsp-completion--get-documentation (item )
473486 " Get doc comment for completion ITEM."
0 commit comments