@@ -171,6 +171,7 @@ This will help minimize popup flickering issue in `company-mode'."
171
171
:_emacsStartPoint start-point)
172
172
item))
173
173
(propertize label
174
+ 'lsp-completion-unresolved-item item
174
175
'lsp-completion-item item
175
176
'lsp-sort-text sort-text?
176
177
'lsp-completion-start-point start-point
@@ -244,9 +245,7 @@ The CLEANUP-FN will be called to cleanup."
244
245
(defun lsp-completion--annotate (item )
245
246
" Annotate ITEM detail."
246
247
(-let (((completion-item &as &CompletionItem :detail? :kind? :label-details? )
247
- (get-text-property 0 'lsp-completion-item item)))
248
- (lsp-completion--resolve-async item #'ignore )
249
-
248
+ (get-text-property 0 'lsp-completion-unresolved-item item)))
250
249
(concat (when (and lsp-completion-show-detail detail?)
251
250
(concat " " (s-replace " \r " " " detail?) ))
252
251
(when (and lsp-completion-show-label-description label-details?)
@@ -455,11 +454,52 @@ The MARKERS and PREFIX value will be attached to each candidate."
455
454
456
455
(defun lsp-completion--get-documentation (item )
457
456
" Get doc comment for completion ITEM."
458
- (-some->> item
459
- (lsp-completion--resolve)
460
- (get-text-property 0 'lsp-completion-item )
461
- (lsp:completion-item-documentation?)
462
- (lsp--render-element)))
457
+ (-let* ((resolved (get-text-property 0 'lsp-completion-resolved item))
458
+ (item (get-text-property
459
+ 0
460
+ (if resolved
461
+ 'lsp-completion-item
462
+ 'lsp-completion-unresolved-item )
463
+ item))
464
+ ((&CompletionItem :detail?
465
+ :documentation? )
466
+ item))
467
+
468
+ (unless (or resolved (and detail? documentation?) )
469
+ (setq item (lsp-completion--resolve item)
470
+ resolved t ))
471
+
472
+ (setq detail? (lsp:completion-item-detail? item)
473
+ documentation? (lsp:completion-item-documentation? item))
474
+
475
+ (when (and detail? documentation?)
476
+ (cond ((lsp-markup-content? documentation?)
477
+ (-let (((&MarkupContent :kind :value ) documentation?) )
478
+ (cond ((and (equal kind " plaintext" )
479
+ (not (string-match-p (regexp-quote detail?) value)))
480
+ (lsp:set-markup-content-value
481
+ documentation?
482
+ (concat detail?
483
+ (if (bound-and-true-p page-break-lines-mode)
484
+ " \n \n "
485
+ " \n\n " )
486
+ value)))
487
+ ((and (equal kind " markdown" )
488
+ (not (string-match-p (regexp-quote detail?) value)))
489
+ (lsp:set-markup-content-value
490
+ documentation?
491
+ (concat " ```\n " detail? " \n ```\n ---\n " value))))))
492
+
493
+ ((and (stringp documentation?)
494
+ (not (string-match-p (regexp-quote detail?) documentation?) ))
495
+ (setq documentation?
496
+ (concat detail?
497
+ (if (bound-and-true-p page-break-lines-mode)
498
+ " \n \n "
499
+ " \n\n " )
500
+ documentation?) ))))
501
+
502
+ (lsp--render-element documentation?) ))
463
503
464
504
(defun lsp-completion--get-context (trigger-characters same-session? )
465
505
" Get completion context with provided TRIGGER-CHARACTERS and SAME-SESSION?."
0 commit comments