Skip to content

Commit

Permalink
Make lsp-completion--resolve[-async] public
Browse files Browse the repository at this point in the history
  • Loading branch information
wyuenho committed Nov 28, 2024
1 parent 5bc2096 commit 1111c94
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions lsp-completion.el
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ See #2675"
(unless (lsp-get data :import_for_trait_assoc_item)
(lsp-put data :import_for_trait_assoc_item :json-false)))))

(defun lsp-completion--resolve (item)
(defun lsp-completion-resolve (item)
"Resolve completion ITEM.
ITEM can be string or a CompletionItem"
(cl-assert item nil "Completion item must not be nil")
Expand All @@ -211,7 +211,9 @@ ITEM can be string or a CompletionItem"
item))
(_ completion-item)))))

(defun lsp-completion--resolve-async (item callback &optional cleanup-fn)
(defalias 'lsp-completion--resolve 'lsp-completion-resolve)

(defun lsp-completion-resolve-async (item callback &optional cleanup-fn)
"Resolve completion ITEM asynchronously with CALLBACK.
The CLEANUP-FN will be called to cleanup."
(cl-assert item nil "Completion item must not be nil")
Expand Down Expand Up @@ -242,6 +244,8 @@ The CLEANUP-FN will be called to cleanup."
(funcall callback completion-item)
(when cleanup-fn (funcall cleanup-fn))))))

(defalias 'lsp-completion--resolve-async 'lsp-completion-resolve-async)

(defun lsp-completion--annotate (item)
"Annotate ITEM detail."
(-let (((completion-item &as &CompletionItem :detail? :kind? :label-details?)
Expand Down Expand Up @@ -466,7 +470,7 @@ The MARKERS and PREFIX value will be attached to each candidate."
completion-item))

(unless (or resolved (and detail? documentation?))
(setq completion-item (get-text-property 0 'lsp-completion-item (lsp-completion--resolve item))
(setq completion-item (get-text-property 0 'lsp-completion-item (lsp-completion-resolve item))
resolved t))

(setq detail? (lsp:completion-item-detail? completion-item)
Expand Down Expand Up @@ -671,7 +675,7 @@ Others: CANDIDATES"
;; see #3498 typescript-language-server does not provide the
;; proper insertText without resolving.
(if (lsp-completion--find-workspace 'ts-ls)
(lsp-completion--resolve candidate)
(lsp-completion-resolve candidate)
candidate))
((&plist 'lsp-completion-item item
'lsp-completion-start-point start-point
Expand Down Expand Up @@ -713,14 +717,14 @@ Others: CANDIDATES"
(not (seq-empty-p additional-text-edits?)))
(lsp--apply-text-edits additional-text-edits? 'completion)
(-let [(callback cleanup-fn) (lsp--create-apply-text-edits-handlers)]
(lsp-completion--resolve-async
(lsp-completion-resolve-async
item
(-compose callback #'lsp:completion-item-additional-text-edits?)
cleanup-fn))))

(if (or resolved command?)
(when command? (lsp--execute-command command?))
(lsp-completion--resolve-async
(lsp-completion-resolve-async
item
(-lambda ((&CompletionItem? :command?))
(when command? (lsp--execute-command command?)))))
Expand Down

0 comments on commit 1111c94

Please sign in to comment.