Function: eglot--async-request

eglot--async-request is a byte-compiled function defined in eglot.el.gz.

Signature

(eglot--async-request SERVER METHOD PARAMS &key (SUCCESS-FN nil SUCCESS-FN-SUPPLIED-P) (ERROR-FN nil ERROR-FN-SUPPLIED-P) (TIMEOUT-FN nil TIMEOUT-FN-SUPPLIED-P) (TIMEOUT nil TIMEOUT-SUPPLIED-P) HINT)

Documentation

Like jsonrpc-async-request, but for Eglot LSP requests.

HINT argument is a symbol passed as DEFERRED to jsonrpc-async-request and also used as a hint of the request cancellation mechanism (see eglot-advertise-cancellation).

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/eglot.el.gz
(cl-defun eglot--async-request (server
                                method
                                params
                                &key
                                (success-fn nil success-fn-supplied-p)
                                (error-fn nil error-fn-supplied-p)
                                (timeout-fn nil timeout-fn-supplied-p)
                                (timeout nil timeout-supplied-p)
                                hint
                                &aux moreargs)
  "Like `jsonrpc-async-request', but for Eglot LSP requests.
HINT argument is a symbol passed as DEFERRED to `jsonrpc-async-request'
and also used as a hint of the request cancellation mechanism (see
`eglot-advertise-cancellation')."
  (cl-labels ((clearing-fn (fn)
                (lambda (&rest args)
                  (when fn (apply fn args))
                  (cl-remf eglot--inflight-async-requests hint))))
    (eglot--cancel-inflight-async-requests (list hint))
    (when timeout-supplied-p
      (setq moreargs (nconc `(:timeout ,timeout) moreargs)))
    (when hint
      (setq moreargs (nconc `(:deferred ,hint) moreargs)))
    (let ((id
           (car (apply #'jsonrpc-async-request
                       server method params
                       :success-fn (clearing-fn success-fn)
                       :error-fn (clearing-fn error-fn)
                       :timeout-fn (clearing-fn timeout-fn)
                       moreargs))))
      (when (and hint eglot-advertise-cancellation)
        (push id
              (plist-get eglot--inflight-async-requests hint)))
      id)))