Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to configure function for formatting code #453

Open
kommen opened this issue Nov 24, 2017 · 1 comment
Open

Ability to configure function for formatting code #453

kommen opened this issue Nov 24, 2017 · 1 comment

Comments

@kommen
Copy link

kommen commented Nov 24, 2017

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?

@bbatsov
Copy link
Member

bbatsov commented Nov 25, 2017

Yeah, certainly.

Ideally this should be done in a way that that doesn't make cider-nrepl depend directly on several libraries, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants