Skip to content
/ fermat Public

An opinionated source code formatter for Erlang

Notifications You must be signed in to change notification settings

youxkei/fermat

Repository files navigation

Fermat

Fermat (/fɛrˈma/, フェルマー) is an opinionated code formatter for Erlang.

Fermat can also remove trailing separators.

Table of Contents

Installation

You can download the binary from the release page.

https://github.com/youxkei/fermat/releases/latest

Usage

Format code with removing trailing separators

$ cat <<EOF > /tmp/foo.erl
-module(foo).
-export([f/1,]).

f() when true,; ->
    [1234567890 || X <- [1234567890,], Y <- [1234567890,], foo:is_valid(X,),],;.
EOF

$ fermat -l 30 /tmp/foo.erl
-module(foo).
-export([f/1]).

f() when true ->
    [1234567890
     || X <- [1234567890],
        Y <- [1234567890],
        foo:is_valid(X)].

Don't format but remove trailing separators

$ cat <<EOF > /tmp/foo.erl
-module(foo).
-export([f/1,]).

f() when true,; ->
    [1234567890 || X <- [1234567890,], Y <- [1234567890,], foo:is_valid(X,),],;.
EOF

$ fermat -n /tmp/foo.erl
-module(foo).
-export([f/1]).

f() when true ->
    [1234567890 || X <- [1234567890], Y <- [1234567890], foo:is_valid(X)].