by ninjakeyboard · 8y ago · 0 comments
Pre commit hook: https://github.com/jasongoodwin/elixir-mix-format-pre-commit...
Emacs format current file: https://github.com/jasongoodwin/emacs-elixir-formatter
Generally the formatter is good, but we've noticed a couple cases where it would be nice to override
EG:
it would be nice to have the join and on statements on the same line so you can see as the reader what relates to what
u in Db.User,
distinct: u.id,
join: c in Db.Comment,
on: u.id == c.user_id,
join: p in Db.Profile,
on: u.profile_id == u.id,
join: x in Db.SomethingElse,
on: x.profile_id == u.id,
join: y in Db.AnotherThing,
on: y.profile_id == u.id,
...I can see why it's like that, but it would be nice to be able to override it.
Also the formatter requires () so you end up with ecto code differing from the styles recommend in the docs
schema "thingy" do
field(:name, :string)
field(:abbreviation, :string)
end
instead of schema "thingy" do
field :name, :string
field :abbreviation, :string
end
Anyway, still useful and good for the team.One of the big advantages I have experienced from the Golang formatter is that you cannot configure it, period. This took me a little bit off getting over myself, but eventually the fact that every single Golang codebase adheres to these rules is so nice. Plus you don't have to think about it, ever.
In this case I think it would be best if Ecto just recommends the new default style in their docs.
Would it be possible to have that be trivially configurable to hook into save-buffer? That would seem to be the cleanest way to use it.