Steamroller is an opinionated Erlang code formatter. Uniformity is inevitable.
Upset your colleagues by autoformatting their code.
This rebar3 plugin is still under development but should be considered reasonably stable. The Erlang abstract syntax tree is checked before and after formatting to make sure that the formatted file is equivalent to the original.
Steamroller should be used as part of your CI to enforce a consistent style across your codebase.
Add steamroller to your rebar config:
{plugins, [steamroller]}.
Then ask it to steamroll your code directly in an existing application:
$ rebar3 steamroll
===> Fetching steamroller
===> Compiling steamroller
<Steamroller Output>
To check that code is properly formatted as part of your CI:
$ rebar3 steamroll --check
The exit code will be non-zero if the code has not been formatted before being committed.
Steamroller comes with sensible default configuration. If you want, you can configure the line length, indent, and input files from your rebar config:
{
steamroller,
[
{line_length, 100},
{indent, 2},
{inputs, ["rebar.config", "{src,test,include}/*.{[he]rl,app.src}"]}
]
}.
You can use steamroller from vim with Neoformat.
Install Neoformat and then paste the below into your vimrc.
" Erlang autoformat
let g:neoformat_erlang_steamroller = {
\ 'exe': 'rebar3',
\ 'args': ['steamroll -f'],
\ 'stdin': 0,
\ 'replace': 1,
\ }
let g:neoformat_enabled_erlang = ['steamroller']
autocmd BufWritePre rebar.config,*.[he]rl,*.app.src Neoformat steamroller
You can use steamroller from Visual Studio Code with the Erlang Formatter extension created by szTheory.
$ rebar3 compile
$ rebar3 test
Dialyzer is Erlang's static analysis tool.
$ rebar3 dialyzer