editors

Discussion about all editors used for Clojure/ClojureScript
mull 2016-03-31T10:14:15.000051Z

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:

sveri 2016-03-31T11:14:33.000052Z

@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.

mull 2016-03-31T11:27:30.000053Z

@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

sveri 2016-03-31T11:30:25.000054Z

@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.

mull 2016-03-31T11:38:18.000055Z

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

sveri 2016-03-31T11:38:42.000056Z

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

sveri 2016-03-31T11:38:52.000057Z

@mull

dominicm 2016-03-31T13:26:24.000058Z

@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.

dominicm 2016-03-31T13:26:53.000059Z

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

dominicm 2016-03-31T13:26:57.000060Z

It just ends up messy.

dominicm 2016-03-31T13:27:21.000061Z

2-char indent, everywhere. Simple and understandable.

mull 2016-03-31T13:34:04.000062Z

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

dominicm 2016-03-31T13:37:38.000063Z

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

dominicm 2016-03-31T13:54:59.000065Z

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

dominicm 2016-03-31T13:55:19.000066Z

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

dominicm 2016-03-31T13:57:11.000067Z

Otherwise that's too ugly! 😛

mull 2016-03-31T14:05:27.000068Z

:simple_smile:

snoe 2016-03-31T15:16:12.000069Z

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

dominicm 2016-03-31T15:24:51.000071Z

woah.

dominicm 2016-03-31T15:37:00.000072Z

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

mull 2016-03-31T15:37:29.000073Z

@snoe: nice!

sveri 2016-03-31T15:55:26.000074Z

@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.

snoe 2016-03-31T15:59:44.000075Z

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

snoe 2016-03-31T16:02:18.000077Z

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

sveri 2016-03-31T16:04:30.000079Z

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

sveri 2016-03-31T16:06:02.000080Z

Aehm, compared to node I mean

snoe 2016-03-31T16:07:08.000081Z

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.

sveri 2016-03-31T16:08:26.000082Z

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