Fork me on GitHub
#cursive
<
2020-11-02
>
pez11:11:57

Does anyone know of cljfmt settings that are somewhat compatible with Cursive defaults?

cfleming10:11:08

I’ve never investigated this, but I’m interested in this too, it would be good to document.

pez10:11:32

How far from the https://github.com/bbatsov/clojure-style-guide#the-clojure-style-guide are the Cursive defaults? Not all that far, right? I see some difference in my day job project, but I am not sure what comes from Cursive settings and what is from its defaults (most people here use Cursive).

pez10:11:55

These are the settings one of my colleagues sent me:

<ClojureCodeStyleSettings>{
  :cljs.core/as-> :only-indent
  :cljs.core/case :only-indent
  :cljs.core/defonce :only-indent
  :clojure.core/case 2
  :compojure.core/defroutes :only-indent
  :cursive.formatting/align-binding-forms true
  :cursive.formatting/comment-align-column 0
  :garden.def/defstyles :only-indent
}</ClojureCodeStyleSettings>

pez10:11:38

The main differences I see are that in the existing code base most re-frame (reg-.* forms and (:require are indented with 2 spaces, while they have no special treatment by cljfmt defaults (i.e. they are indented with 1 space).

pez10:11:02

I seem to make Calva mostly behave together with Cursive on this project using this cjfmt.edn:

{:remove-surrounding-whitespace? true
 :remove-trailing-whitespace? true
 :remove-consecutive-blank-lines? false
 :insert-missing-whitespace? true
 :align-associative? true
 :indents {#"^reg-" [[:inner 0]]
           #"^:require" [[:block 0]]}}
(Note that align-associative? isn’t standard cljfmt , it is just on my fork. And it doesn’t behave nearly as stellar as Cursive’s one.)

pez10:11:57

I’ll let you know if I find out enough about this to provide https://calva.io/formatting/ with a settings example for Cursive defaults compatibility.