weavejester/cljfmt

Configurable namespace sorting

hxegon opened this issue · 1 comments

I'd like to sort the namespaces in a non-alphabetical way: clojure core libraries first, followed by external namespaces, and then internal namespaces. Feels like it'd be simple to add on top of #251, after that's merged I can take a crack at it.

Thinking it could be configured by either:

  • user supplied fn arg to sort-by passed to sort-ns-references (not sure how a user supplied fn would work in an edn config)
  • a :sort-ns-regexes option, a vector of regexes matching the required namespaces in order of sorting rank

This would let me do that while opening it up to whatever order people would like, and could default to alphabetical sorting

I had issues with regex in edn when testing some things with indentation rules. Maybe something like

{:clojure       :top
 :project-ns :bottom}

or just using prefix instead of full regex in the config

[{:prefix "clojure" :order 0}
 {:prefix "my.proj" :order 10}