Circle CIHex versionAPI DocsLicence

exfmt 🌸

exfmt is in alpha. If you run into any problems, please report them.

Currently exfmt does not always produce semantically identical formatted Elixir. There are checks to prevent data loss, but please ensure you have backed up your code before running exfmt during this alpha stage.

The format produced by exfmt will change significantly before the 1.0.0 release. If this will cause problems for you, please refrain from using exfmt during the alpha- and beta-test periods.

exfmt is inspired by Aaron VonderHaar's elm-format, and aims to formats Elixir source code largely according to the standards defined in Aleksei Magusev's Elixir Style Guide.

# exfmt takes any Elixir code...

defmodule MyApp, do: (
    use( SomeLib )
    def run( data ), do: {
      :ok,
      data
   }
)

# and rewrites it in a clean and idiomatic style:

defmodule MyApp do
  use SomeLib

  def run(data) do
    {:ok, data}
  end
end

The benefits of exfmt:

Contents

Usage

# Preview the exfmt formatting of an Elixir source file
mix exfmt path/to/file.ex

Editor integration

Atom

Atom users can install the exfmt-atom package.

Vim

Vim users can use exfmt with Steve Dignam's Neoformat.

Once installed the following config will enable formatting of the current Elixir buffer using :Neoformat. For further instructions, please reference the Neoformat documentation.

let g:neoformat_elixir_exfmt = {
  \ 'exe': 'mix',
  \ 'args': ['exfmt', '--stdin'],
  \ 'stdin': 1
  \ }

let g:neoformat_enabled_elixir = ['exfmt']

Development

exfmt is an open project, contributions are very much welcomed. If you have feedback or have found a bug, please open an issue. If you wish to make a code contribution please open a pull request, though for larger code changes it may be good to open an issue first so we can work out the best way to move forward.

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

# Install the deps
mix deps.get

# Run the tests
mix test

# Run the tests when files change
mix test.watch

# Run the type checker
mix dialyzer