Current section
Files
Jump to
Current section
Files
steamroller
README.md
README.md
🚂 Steamroller==============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. TheErlang abstract syntax tree is checked before and after formatting to make sure that the formattedfile is equivalent to the original.Steamroller should be used as part of your CI to enforce a consistent style across your codebase.## UseAdd 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>## ConfigureSteamroller comes with sensible default configuration. If you want, you can configure the linelength, indent, and input files from your rebar config: { steamroller, [ {line_length, 100}, {indent, 2}, {inputs, ["rebar.config", "{src,test}/**/*.{[he]rl,app.src}"]} ] }.## Editor Integration### VimYou can use steamroller from vim with [Neoformat](https://github.com/sbdchd/neoformat).Install Neoformat and then paste the below into your vimrc.```viml" Erlang autoformatlet 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```### Visual Studio CodeYou can use steamroller from Visual Studio Code with the[Erlang Formatter](https://marketplace.visualstudio.com/items?itemName=szTheory.erlang-formatter)extension created by [szTheory](https://github.com/szTheory).## CITo check that code is properly formatted as part of your CI: $ rebar3 steamroll --checkThe exit code will be non-zero if the code has not been formatted before being committed.## Build $ rebar3 compile## Test $ rebar3 test## DialyzerDialyzer is Erlang's static analysis tool. $ rebar3 dialyzer## Local DevelopmentIn order to use steamroller locally on itself you need to symlink the repo into the \_checkoutsdirectory: cd $local_steamroller_repo mkdir _checkouts ln -s $PWD ./_checkouts/steamrollerRebar3 will use the version of steamroller in the \_checkouts directory with higher priority thanthe version specified in the rebar.config. There's a line in the rebar.config (see `overrides`)which prevents infinite plugin loops when using steamroller locally like this.