marcandre

marcandre

Trailing commas + mix format

For people that love trailing commas, I released v2.0 of the freedom formatter. It is now a plugin for the builtin formatter (requires Elixir 1.13.2+).

Note that elixir-ls’s next release will support formatting plugins.

Thanks to José Valim for making formatter plugins possible :heart:, and Pete Gamache for the initial version of the freedom_formatter.

Most Liked

arcanemachine

arcanemachine

I stumbled on this thread after getting yet another compilation error from shuffling around the values in a long list (obviously, I moved the last one somewhere else in the list).

I think trailing commas are ugly, but they are simply more functional: Cleaner diffs, and makes it easier to shuffle values around.

Thanks for making this project! One less annoyance to babysit. :slight_smile:

Sebb

Sebb

What do you think about adding tabular code formatting?

And what do you think about making the formatter bringing all clauses to a single line when possible, eg here when the inspect is removed:

case number do
  1 ->
    :one

  2 ->
    :two

  3 ->
    :three

  number ->
    IO.inspect(number)
    :very_big
end
marcandre

marcandre

Thanks for your question and interest :slight_smile:

I welcome PRs for new features. At first sight, both of these seem acceptable. Care must be taken into when they would trigger or not and have good test coverage.

I personally do not intend to actually write the implementation for any new option. Trailing commas is what I am interested in. It is in my mind a different beast than the rest because it is not about readability or esthetics, it is about ease of editing and about minimizing diffs. I doubt I will propose to my colleagues to use other formatting options.

If someone else writes them, I will gladly review them and maintain them though.

Where Next?

Popular in Discussions Top

mbenatti
Following https://github.com/tbrand/which_is_the_fastest |> https://raw.githubusercontent.com/tbrand/which_is_the_fastest/master/imgs...
New
nburkley
AWS re:Invent is on at the moment with some interesting announcements. One new feature in particular is the Lambda Runtime API for AWS La...
New
Nvim
Anybody knows a comprehensive comparison of Django and Phoenix, thanks for the help. Where are they similar? Where do they differ the m...
New
tomekowal
Hey guys! I want to create a toy project that shows a chart of temperature over time and updates every 5 seconds. I feel LiveView is per...
New
Nvim
Elixir appears to be a superior language to Python. I don’t see any advantage of Python over Elixir. Are there any?
New
fireproofsocks
I’ve been working on an Elixir project that has required a lot of scripting. I usually reach for Elixir because I like it more (and in th...
New
arcanemachine
https://nitter.net/josevalim/status/1744395345872683471 https://twitter.com/josevalim/status/1744395345872683471
New

Other popular topics Top

New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New

We're in Beta

About us Mission Statement