Function: cider-sync-request:format-code

cider-sync-request:format-code is a byte-compiled function defined in cider-client.el.

Signature

(cider-sync-request:format-code CODE &optional FORMAT-OPTIONS)

Documentation

Perform nREPL "format-code" op with CODE.

FORMAT-OPTIONS is an optional configuration map for cljfmt.

Source Code

;; Defined in ~/.emacs.d/elpa/cider-20260414.1619/cider-client.el
(defun cider-sync-request:format-code (code &optional format-options)
  "Perform nREPL \"format-code\" op with CODE.
FORMAT-OPTIONS is an optional configuration map for cljfmt."
  (let* ((request `("op" "format-code"
                    "options" ,(cider--nrepl-format-code-request-options format-options)
                    "code" ,code))
         (response (cider-nrepl-send-sync-request request))
         (err (nrepl-dict-get response "err")))
    (when err
      ;; err will be a stacktrace with a first line that looks like:
      ;; "clojure.lang.ExceptionInfo: Unmatched delimiter ]"
      (error (car (split-string err "\n"))))
    (nrepl-dict-get response "formatted-code")))