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