@@ -190,7 +190,7 @@ See #2675"
190
190
(unless (lsp-get data :for_ref )
191
191
(lsp-put data :for_ref :json-false )))))
192
192
193
- (defun lsp-completion-resolve (item )
193
+ (defun lsp-completion-- resolve (item )
194
194
" Resolve completion ITEM.
195
195
ITEM can be string or a CompletionItem"
196
196
(cl-assert item nil " Completion item must not be nil" )
@@ -215,9 +215,7 @@ ITEM can be string or a CompletionItem"
215
215
item))
216
216
(_ completion-item)))))
217
217
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 )
221
219
" Resolve completion ITEM asynchronously with CALLBACK.
222
220
The CLEANUP-FN will be called to cleanup."
223
221
(cl-assert item nil " Completion item must not be nil" )
@@ -248,12 +246,10 @@ The CLEANUP-FN will be called to cleanup."
248
246
(funcall callback completion-item)
249
247
(when cleanup-fn (funcall cleanup-fn))))))
250
248
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."
255
251
(-let (((completion-item &as &CompletionItem :detail? :kind? :label-details? )
256
- ( get-text-property 0 'lsp-completion-unresolved- item item) ))
252
+ item))
257
253
(concat (when (and lsp-completion-show-detail detail?)
258
254
(concat " " (s-replace " \r " " " detail?) ))
259
255
(when (and lsp-completion-show-label-description label-details?)
@@ -263,6 +259,12 @@ The CLEANUP-FN will be called to cleanup."
263
259
(when-let* ((kind-name (and kind? (aref lsp-completion--item-kind kind?) )))
264
260
(format " (%s ) " kind-name))))))
265
261
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
+
266
268
(defun lsp-completion--looking-back-trigger-characterp (trigger-characters )
267
269
" Return character if text before point match any of the TRIGGER-CHARACTERS."
268
270
(unless (= (point ) (line-beginning-position ))
@@ -460,12 +462,19 @@ The MARKERS and PREFIX value will be attached to each candidate."
460
462
(setq label-pos 0 )))
461
463
matches)))
462
464
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
+
463
472
(defun lsp-completion--get-documentation (item )
464
473
" Get doc comment for completion ITEM."
465
474
(or (get-text-property 0 'lsp-completion-item-doc item)
466
475
(-let* (((&CompletionItem :detail?
467
476
: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)))
469
478
(doc
470
479
(if (and detail? documentation?)
471
480
; ; 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."
647
656
(goto-char (1- (point ))))
648
657
(and triggered-by-char? t )))
649
658
:company-match #'lsp-completion--company-match
659
+ :company-docsig #'lsp-completion--company-docsig
650
660
:company-doc-buffer (-compose #'lsp-doc-buffer
651
661
#'lsp-completion--get-documentation )
652
662
:exit-function
@@ -669,7 +679,7 @@ Others: CANDIDATES"
669
679
; ; see #3498 typescript-language-server does not provide the
670
680
; ; proper insertText without resolving.
671
681
(if (lsp-completion--find-workspace 'ts-ls )
672
- (lsp-completion-resolve candidate)
682
+ (lsp-completion-- resolve candidate)
673
683
candidate))
674
684
((&plist 'lsp-completion-item item
675
685
'lsp-completion-start-point start-point
@@ -711,14 +721,14 @@ Others: CANDIDATES"
711
721
(not (seq-empty-p additional-text-edits?) ))
712
722
(lsp--apply-text-edits additional-text-edits? 'completion )
713
723
(-let [(callback cleanup-fn) (lsp--create-apply-text-edits-handlers)]
714
- (lsp-completion-resolve-async
724
+ (lsp-completion-- resolve-async
715
725
item
716
726
(-compose callback #'lsp:completion-item-additional-text-edits? )
717
727
cleanup-fn))))
718
728
719
729
(if (or resolved command?)
720
730
(when command? (lsp--execute-command command?) )
721
- (lsp-completion-resolve-async
731
+ (lsp-completion-- resolve-async
722
732
item
723
733
(-lambda ((&CompletionItem? :command? ))
724
734
(when command? (lsp--execute-command command?) ))))
0 commit comments