cljfmt icon indicating copy to clipboard operation
cljfmt copied to clipboard

Linebreaking and re-indenting?

Open danielcompton opened this issue 7 years ago • 5 comments
trafficstars

These forms are both treated by lein-cljfmt 0.5.7 as fine and not needing any repair, even though neither is very idiomatic Clojure.

(ns test1
     (:require [clojure.edn :as edn]
               [clojure.java.io :as io]))
(ns test1 (:require [clojure.edn :as edn] [clojure.java.io :as io]))

What are your thoughts on making cljfmt re-indent files, and also break them (in some circumstances, probably can't always do this)?

My dream is for a Clojure formatting tool which would always converge to reformat to the same file, no matter how much whitespace was (or wasn't) in between the tokens in the original file. I'm not sure how opinionated cljfmt wants to be though?

danielcompton avatar May 05 '18 11:05 danielcompton

I think that's a good idea; however, my goal with cljfmt wasn't to provide a canonical format, but to fix any formatting issues that were obviously wrong.

Have you looked into zprint? You may find that more what you want to do.

weavejester avatar May 05 '18 14:05 weavejester

I’ve seen zprint, it does do more breaking than cljfmt, but is extremely configurable. Ideally I’d use a tool with zero/minimal config.

danielcompton avatar May 05 '18 19:05 danielcompton

@weavejester, @danielcompton now that cljfmt README states that "it is not the goal of cljfmt to provide a canonical format" should this issue be closed?

lread avatar Dec 15 '18 00:12 lread

I actually don't mind the idea of splitting up long lines. The Clojure style guide recommends that lines don't exceed 80 characters, and that's my own preference as well. It would be nice if cljfmt had an (optional) mechanism for splitting up lines over 80 characters in an idiomatic way.

weavejester avatar Dec 15 '18 00:12 weavejester

Popping my head in to add support for this suggestion. Doing a lot of line-breaking by hand at the minute :)

yochannah avatar Apr 26 '19 11:04 yochannah