elm-format
is still in alpha. If you run into any problems, please report them.The format produced by elm-format may change significantly before the 1.0.0 release. If this will cause problems for you, please refrain from using elm-format during the alpha- and beta-test periods.
elm-format
formats Elm source code according to a standard set of rules. It is inspired by the popular gofmt.
The benefits of elm-format
:
- It makes code easier to write, because you never have to worry about minor formatting concerns while powering out new code.
- It makes code easier to read, because there are no longer distracting minor stylistic differences between different code bases. As such, your brain can map more efficiently from source to mental model.
- It makes code easier to maintain, because you can no longer have diffs related only to formatting; every diff necessarily involves a material change.
- It saves your team time debating how to format things, because there is a standard tool that formats everything the same way.
elm-format Main.elm # Format a single file
elm-format Main.elm --yes # Overwrite the file without prompting
elm-format src/ # Format all *.elm files in a directory
elm-format --stdin # Format input from stdin and write to stdout
elm-format --stdin --output Main.elm # Format input from stdin and write to file
elm-format --help # See other command line options
elm-format
is still in alpha. If you run into any problems, please report them.The format produced by elm-format may change significantly before the 1.0.0 release. If this will cause problems for you, please refrain from using elm-format during the alpha- and beta-test periods.
You will need to download the version appropriate for your OS, unzip it, and place elm-format
or elm-format.exe
(windows) on your PATH
. Simpler installation options will be available once there is a stable release of elm-format.
If you need PGP signatures, see the releases page.
(Using this version with Elm 0.16 files will migrate them to Elm 0.17 syntax.)
If you can simplify or improve the installation instructions or add instructions for another editor, please make a pull request. The default behavior of elm-format
-approved plugins is to format Elm files on save.
Integration with Atom
atom-elm-format supports elm-format
. You can install elm-format
using apm
or the Atom package manager in Atom's settings.
atom-beautify 0.28.20 and above supports elm-format
. You can install atom-beautify
using apm
or the Atom package manager in Atom's settings.
Integration with Light Table
- Makes sure
elm-format
is in your PATH - Install the elm-light plugin using the Light Table plugin manager
- Add the following to your user keymap:
[:editor.elm "ctrl-s" :save :elm-format :elm.lint]
- Make sure
elm-format
is in your PATH. - Install elm-vim (instructions)
- Add the following to your
.vimrc
file:
let g:elm_format_autosave = 1
- Install elm-mode (instructions).
- Make sure
elm-format
is in your PATH.
That's all.
After the install C-c C-f (in elm-mode
) runs the command elm-mode-format-buffer which is based on elm-format
.
See also the respective section about elm-format
at elm-mode
Use the Elm Language Support package. Make sure elm-format is in your PATH.
- Make sure
elm-format
is in your PATH. ext install elm
to get the Elm tools for VSCode, which also know about elm-format.- You don't need the "elm-format" listed in the VSCode package-available list.
- shift-alt-F or similar will call elm-format on the current file.
git clone https://github.com/avh4/elm-format.git
cd elm-format
cabal sandbox init
cabal install --only-dependencies --enable-tests
cabal build
./dist/build/elm-format-0.17/elm-format-0.17 --help
brew install shellcheck
cabal configure --enable-tests
./tests/run-tests.sh