Does anyone know of cljfmt
settings that are somewhat compatible with Cursive defaults?
I’ve never investigated this, but I’m interested in this too, it would be good to document.
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).
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>
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).
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.)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.