@@ -190,7 +190,7 @@ See #2675"
190190 (unless (lsp-get data :for_ref )
191191 (lsp-put data :for_ref :json-false )))))
192192
193- (defun lsp-completion-resolve (item )
193+ (defun lsp-completion-- resolve (item )
194194 " Resolve completion ITEM.
195195ITEM can be string or a CompletionItem"
196196 (cl-assert item nil " Completion item must not be nil" )
@@ -215,9 +215,7 @@ ITEM can be string or a CompletionItem"
215215 item))
216216 (_ completion-item)))))
217217
218- (defalias 'lsp-completion--resolve 'lsp-completion-resolve )
219-
220- (defun lsp-completion-resolve-async (item callback &optional cleanup-fn )
218+ (defun lsp-completion--resolve-async (item callback &optional cleanup-fn )
221219 " Resolve completion ITEM asynchronously with CALLBACK.
222220The CLEANUP-FN will be called to cleanup."
223221 (cl-assert item nil " Completion item must not be nil" )
@@ -248,12 +246,10 @@ The CLEANUP-FN will be called to cleanup."
248246 (funcall callback completion-item)
249247 (when cleanup-fn (funcall cleanup-fn))))))
250248
251- (defalias 'lsp-completion--resolve-async 'lsp-completion-resolve-async )
252-
253- (defun lsp-completion--annotate (item )
254- " Annotate ITEM detail."
249+ (defun lsp-completion--get-label-detail (item )
250+ " Construct label detail from completion item ITEM."
255251 (-let (((completion-item &as &CompletionItem :detail? :kind? :label-details? )
256- ( get-text-property 0 'lsp-completion-unresolved- item item) ))
252+ item))
257253 (concat (when (and lsp-completion-show-detail detail?)
258254 (concat " " (s-replace " \r " " " detail?) ))
259255 (when (and lsp-completion-show-label-description label-details?)
@@ -263,6 +259,12 @@ The CLEANUP-FN will be called to cleanup."
263259 (when-let* ((kind-name (and kind? (aref lsp-completion--item-kind kind?) )))
264260 (format " (%s ) " kind-name))))))
265261
262+ (defun lsp-completion--annotate (cand )
263+ " Annotation function for completion candidate CAND.
264+
265+ Returns unresolved completion item detail."
266+ (lsp-completion--get-label-detail (get-text-property 0 'lsp-completion-unresolved-item cand)))
267+
266268(defun lsp-completion--looking-back-trigger-characterp (trigger-characters )
267269 " Return character if text before point match any of the TRIGGER-CHARACTERS."
268270 (unless (= (point ) (line-beginning-position ))
@@ -460,12 +462,19 @@ The MARKERS and PREFIX value will be attached to each candidate."
460462 (setq label-pos 0 )))
461463 matches)))
462464
465+ (defun lsp-completion--company-docsig (cand )
466+ " Signature for completion candidate CAND.
467+
468+ Returns resolved completion item details."
469+ (and (lsp-completion--resolve cand)
470+ (lsp-completion--get-label-detail (get-text-property 0 'lsp-completion-item cand))))
471+
463472(defun lsp-completion--get-documentation (item )
464473 " Get doc comment for completion ITEM."
465474 (or (get-text-property 0 'lsp-completion-item-doc item)
466475 (-let* (((&CompletionItem :detail?
467476 :documentation? )
468- (get-text-property 0 'lsp-completion-item (lsp-completion-resolve item)))
477+ (get-text-property 0 'lsp-completion-item (lsp-completion-- resolve item)))
469478 (doc
470479 (if (and detail? documentation?)
471480 ; ; detail was resolved, that means the candidate list has no
@@ -647,6 +656,7 @@ The MARKERS and PREFIX value will be attached to each candidate."
647656 (goto-char (1- (point ))))
648657 (and triggered-by-char? t )))
649658 :company-match #'lsp-completion--company-match
659+ :company-docsig #'lsp-completion--company-docsig
650660 :company-doc-buffer (-compose #'lsp-doc-buffer
651661 #'lsp-completion--get-documentation )
652662 :exit-function
@@ -669,7 +679,7 @@ Others: CANDIDATES"
669679 ; ; see #3498 typescript-language-server does not provide the
670680 ; ; proper insertText without resolving.
671681 (if (lsp-completion--find-workspace 'ts-ls )
672- (lsp-completion-resolve candidate)
682+ (lsp-completion-- resolve candidate)
673683 candidate))
674684 ((&plist 'lsp-completion-item item
675685 'lsp-completion-start-point start-point
@@ -711,14 +721,14 @@ Others: CANDIDATES"
711721 (not (seq-empty-p additional-text-edits?) ))
712722 (lsp--apply-text-edits additional-text-edits? 'completion )
713723 (-let [(callback cleanup-fn) (lsp--create-apply-text-edits-handlers)]
714- (lsp-completion-resolve-async
724+ (lsp-completion-- resolve-async
715725 item
716726 (-compose callback #'lsp:completion-item-additional-text-edits? )
717727 cleanup-fn))))
718728
719729 (if (or resolved command?)
720730 (when command? (lsp--execute-command command?) )
721- (lsp-completion-resolve-async
731+ (lsp-completion-- resolve-async
722732 item
723733 (-lambda ((&CompletionItem? :command? ))
724734 (when command? (lsp--execute-command command?) ))))
0 commit comments