Skip to content

Ability to configure function for formatting code #453

Open
@kommen

Description

@kommen

It would be nice to have the ability to configure the function used for formatting code (i.e cider-format-buffer).

The relevant repl middleware function:

(def ^:private reformat-string
(delay
(do
(require 'cljfmt.core)
(resolve 'cljfmt.core/reformat-string))))

We'd like to use https://github.com/kkinnear/zprint instead cljfmt.

For pretty printing, configuring the desired library is already supported:

(defn- resolve-pprint-fn
[sym]
(if-let [pp-fn (-> sym u/as-sym find-var)]
pp-fn
(throw (IllegalArgumentException. (format "%s is not resolvable to a var" sym)))))

For now, and in case somebody else wants to use zprint with cider, we use the following approach to change reformat-string:

(alter-var-root
  #'cider.nrepl.middleware.format/reformat-string
  (constantly (delay #(zprint/zprint-file-str % "<stdin>")))

Is the ability to configure this properly and out of the box, like for pretty printing, something the project would be interested in?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions