Fork me on GitHub
#editors
<
2016-03-31
>
mull10:03:15

What do you guys use within a project to have consistent formatting? cljfmt looks like the standard way to go & integrates nicely with vim & CIDER. We’re creating our first (yay!) collaborative Clojure projects now and noticed that our setups aren’t quite compatible. If I saved my co-workers file using my setup it would automatically fix (as in cljfmt fix) the file. We’re looking to reach a consensus, open to everything, so I’m hoping you guys can share your experiences. simple_smile

sveri11:03:33

@mull: This is not clojure specific, but the usual way to go is to format the code as part of the pre commit job, if your build chain allows that. Another solution is to autoformat on save if the editor supports this option.

mull11:03:30

@sveri: auto format on save is what I would go for as well. Pre-commit is an interesting idea. From my vim-cljfmt it sometimes screws things up though so I can imagine it could get a bit messy

sveri11:03:25

@mull: I never tested it for cljfmt, but, if I was serious on it in a team environment I would take my time and try to make it work reliably. That's what our team does for java code formatting, we solved it by having an installchain containing eclipse and the same format settings enabled for everyone on file save. So there are different solutions, just make sure they work reliable for everyone to reduce developer pain.

mull11:03:18

@sveri: thanks for your input, we appreciate it simple_smile

sveri11:03:42

@mill yw, be creative, I am sure you find something simple_smile

dominicm13:03:24

@mull we eventually gave up on getting emacs/vim/cursive to all play together nicely. We eventually settled on just using 2-indents for everything.

dominicm13:03:53

Emacs has it's own list of "special" 1-indents, and clojure-static has it's list, no idea how cursive determines it.

dominicm13:03:57

It just ends up messy.

dominicm13:03:21

2-char indent, everywhere. Simple and understandable.

mull13:03:04

@dominicm: Makes sense. Though 2-char indent everywhere doesn’t end up as pretty :’)

dominicm13:03:38

In most cases you don't notice the 1v2 difference. Or is there something I've missed?

dominicm13:03:59

Oh, we align if there is an argument on the first line.

dominicm13:03:19

I was talking about indenting macros with 1 space, and fns with 2 spaces.

dominicm13:03:11

Otherwise that's too ugly! 😛

snoe15:03:12

@mull I created this so you can do fast pre-commit hooks. https://github.com/snoe/node-cljfmt

dominicm15:03:00

@snoe you've really solved the general tooling problem by using js. It's really cool.

mull15:03:29

@snoe: nice!

sveri15:03:26

@snoe: I know its open source and all, but why not make a leiningen task / plugin or some kind of a jar? Having to install nodejs for formatting clojure code is strange 😄 Well, I dont want to criticize you. Always nice to see stuff given back to the community. Just wondering about so many people going nodejs today.

snoe15:03:44

simply for speed, there's https://github.com/weavejester/cljfmt if you want a plugin

snoe16:03:18

I think asking that question about node but not about java is a historical accident. simple_smile troll

sveri16:03:30

@snoe: Ah, awesome. Is it so much slower compared to clojure?

sveri16:03:02

Aehm, compared to node I mean

snoe16:03:08

for a commit hook, I was super frustrated with starting up jvm and clojure on each commit (and a repl call wouldn't work on our team) it's 2-3 seconds of wait. the startup time for cljs is basically instant.

sveri16:03:26

Got it and I have to agree, having to wait for every commit sucks.