• Stars
    star
    1,309
  • Rank 35,952 (Top 0.8 %)
  • Language
    Haskell
  • License
    BSD 3-Clause "New...
  • Created about 9 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

elm-format formats Elm source code according to a standard set of rules based on the official Elm Style Guide

Build Status latest version: 0.8.7

elm-format

elm-format formats Elm source code according to a standard set of rules based on the official Elm Style Guide. 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.
  • It saves you time because you don't have to nitpick over formatting details of your code.

Usage

elm-format .  # Format all *.elm files in the current directory
elm-format Main.elm  # Format a single file
elm-format Main.elm --yes  # Overwrite the file without prompting
elm-format src/ Main.elm  # Format the listed files and directories
elm-format --help  # See other command line options

Installation (latest version: 0.8.7)

To install elm-format:

npm install -g elm-format

or download the version appropriate for your OS from the release page, unzip it, and place elm-format or elm-format.exe (windows) on your PATH.

You must run elm-format from the directory that contains your elm.json (for Elm 0.19) or elm-package.json (for Elm 0.18), or else you must pass the appropriate --elm-version=0.19/--elm-version=0.18 command line argument.

Editor integration

Find your editor in the table below. The recommended plugin for each editor is indicated with πŸ† (trophy emoji).

Editor Plugin Installation Formatting Format on save Configuration Error handling
Atom πŸ† atom-elm-format βœ… 2 steps βœ… βœ… βœ… ⚠️ no installation instructions
atom-beautify ⚠️ 3 steps βœ… ⚠️ requires configuration βœ… βœ…
Light Table πŸ† elm-light ⚠️ 3 steps βœ… ⚠️ requires configuration βœ… ⚠️ no installation instructions
Vim πŸ† elm-vim ❌ 6 steps βœ… ⚠️ requires configuration βœ… ❌ no error message
Emacs πŸ† elm-mode ❌ 4 steps βœ… ⚠️ requires configuration βœ… ⚠️ no installation instructions
Visual Studio Code πŸ† Elm Tooling ⚠️ 3 steps βœ… ⚠️ requires configuration βœ… ❌ uninformative error message
Sublime Text πŸ† Elm Language Support βœ… 2 steps ❔ TBD βœ… ❔ TBD ❔ TBD
JetBrains (WebStorm, etc) πŸ† intellij-elm ⚠️ 4 steps βœ… ⚠️ requires configuration ⚠️ requires configuration ❔ TBD
TextMate πŸ† Elm.tmbundle βœ… 2 steps ❔ TBD ❔ TBD ❔ TBD ❔ TBD

Integration with other tools

These tools also integrate with elm-format:

Detailed installation instructions

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.

atom-elm-format installation

  1. Install elm-format

  2. Install atom-elm-format

    apm install elm-format
    

or use the Atom package manager in Atom's settings

atom-beautify installation

  1. Install elm-format

  2. Install atom-beautify

    apm install atom-beautify
    

or use the Atom package manager in Atom's settings

  1. Use ^βŒ₯B (CTRL-ALT-B) to format a file

elm-light installation

  1. Install elm-format
  2. Install the elm-light plugin using the Light Table plugin manager
  3. To format on save, edit your user keymap by performing the following:
  • Click File -> Settings -> User Keymap to open the user keymap.
  • Copy the following line and paste it into your keymap. Anywhere is fine as long as it is whithin the outer brackets. Ensure to save the file.
[:editor.elm "ctrl-s" :save :elm-format :elm.lint]
  • Search for "App: Reload keymaps" in the Commands Window to apply the changes (or restart LightTable).

elm-mode installation

  1. Install elm-format

  2. If your Emacs has package.el (which is automatically the case for Emacs >= 24), you can install elm-mode from the package in MELPA:

    1. Ensure that you have added the MELPA source in your ~/.emacs.d/init.el:

      (require 'package)
      (add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/"))
    2. Install elm-mode (official instructions): Use M-x list-packages and choose elm-mode.

  3. Add the following to your ~/.emacs.d/init.el:

    (add-hook 'elm-mode-hook 'elm-format-on-save-mode)

elm-vim installation

If you are an advanced vim user and already have a preferred vim plugin installation method, you may prefer to refer to the official elm-vim installation instructions. The instructions below are for those who need a step-by-step walkthrough of how to get the plugin set up.

  1. Install elm-format

  2. Install vim-plug (official instructions) NOTE: if you are using neovim, you will need to refer to the official instructions.

    1. Download vim-plug:

      curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
          https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
    2. Make sure ~/.vimrc exists and has a section like this:

      call plug#begin('~/.vim/plugged')
      " ... any active plugins
      call plug#end()
  3. Install elm-vim (official instructions)

    1. Add Plug 'elmcast/elm-vim' to the plug#begin plugin section in your ~/.vimrc
    2. Start vim and run :PlugInstall
  4. Add the following to your ~/.vimrc:

let g:elm_format_autosave = 1

Visual Studio Code installation

  1. Install elm-format

  2. Install the extension Elm Plugin for Visual Studio Code.

  3. Configure the extension to format on save:

    1. Find your settings.json file (instructions).
    2. Add the following key-value pair to your settings.json:
    "[elm]": {
        "editor.formatOnSave": true
    },

Sublime Text installation

  1. Install elm-format
  2. Install the Elm Language Support package.

JetBrains installation

This is for WebStorm and other JetBrains IDEs like IntelliJ and PyCharm.

  1. Install elm-format

  2. Install the intellij-elm plugin

  3. In IntelliJ, open Settings -> Languages & Frameworks -> Elm

    1. Specify the path to elm-format (try the "Auto Discover" button first)
    2. Check the "Run when file saved?" checkbox

Development info

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.

Use the instructions below to get started. More detailed information is available in ./dev/Documentation/.

Building from source

  1. Install Haskell ghcup following the instructions for your operating system: https://www.haskell.org/ghcup/
# check out the repo
git clone https://github.com/avh4/elm-format.git
cd elm-format

# initial setup
ghcup install ghc 9.4.4
ghcup set ghc 9.4.4
cabal install hpack

# build
dev/build.sh -- build

# run the built elm-format
./_build/bin/elm-format/O0/elm-format

See dev/Documentation for more contributor and build command documentation.

More Repositories

1

elm-upgrade

Upgrade Elm projects
Perl
122
star
2

elm-program-test

Test Elm programs
Elm
93
star
3

elm-beautiful-example

Create beautiful examples to show off your Elm packages and projects
Elm
49
star
4

elm-desktop-app

the simplest way to write desktop applications in Elm
Elm
45
star
5

elm-testable

Makes Cmds and Tasks testable
Elm
41
star
6

binwrap

Distribute binaries via npm
JavaScript
38
star
7

time-tracker-for-mac

This repository is out of date-- use the SVN repository at http://code.google.com/p/time-tracker-mac/source/browse/
Objective-C
34
star
8

codevember-2016

30 Elm graphics experiments (WebGL, SVG, HTML)
HTML
33
star
9

elm-mario

The Elm Mario example updated for Elm 0.18
HTML
28
star
10

hero-extant

Java port of Hero Extant: World Generator - This world generator uses fractal terrains and various simulations to generate highly detailed random map data.
Java
23
star
11

elm-debug-controls

Easily build interactive UIs for complex data structures
Elm
23
star
12

elm-color

Standard representation of colors, encouraging sharing between packages. (This replaces elm-lang/core#Color from Elm 0.18.)
Elm
21
star
13

elm-aws-cognito

Example of using AWS Cognito in Elm via ports
Elm
21
star
14

elm-animations

Elm
17
star
15

elm-dropbox

Unofficial Dropbox API for Elm
Elm
15
star
16

junit-nested

JUnit-Nested - Testing tool for Java
Java
15
star
17

imagecomparison

Tools for comparing images and writing image-based approval tests. This library is published on Maven Central.
Java
8
star
18

elm-github-v3

Unofficial GitHub v3 API for Elm
Elm
8
star
19

elm-spec

Elm
7
star
20

elm-compile-html

Compile HTML templates into Elm code
Elm
7
star
21

khan-academy

Fork of the hg repository: Khan Academy main web application
Python
7
star
22

sleep-as-android-parser

JavaScript
6
star
23

burndown-charts

A library for plotting burndown charts
Elm
6
star
24

ruby-sync

sync local directories to FTP
Ruby
6
star
25

jbehave-junit-monitor

fine grained monitoring of jbehave scenarios using junit runner (fork from svn project)
Java
5
star
26

elm-diff

Elm
5
star
27

elm-favicon

Get icons for URLs
Elm
5
star
28

rubyviz

generate diagrams of class and method collaboration in ruby to aid in refactoring
Ruby
5
star
29

picocontainer-example

How to use PicoContainer with dynamically-created dependencies
Java
4
star
30

rbiphonetest-example

An example of using rbiphonetest and playing around to add rspec support.
Objective-C
4
star
31

react-charts

SVG charting library for React.js
JavaScript
4
star
32

map-toolkit

Java
4
star
33

elm-refactor

4
star
34

system_keychain

Store account credentials in the OS keychain
Ruby
3
star
35

elm-meshes

3D meshes (useful for WebGL in Elm)
Elm
3
star
36

jfugue

Mirror of subversion repository: JFugue - Java API for Music Programming
Java
3
star
37

ocmock

git mirror of the OCMock subversion repository
Objective-C
3
star
38

elm-fifo

first in, first out (FIFO) queue
Elm
3
star
39

elm-realtime-drive

Elm bindings for Google Drive Realtime API
JavaScript
3
star
40

elm-dataviz

simple rendering of tabular data
Elm
3
star
41

scratch

A scratch space for trying out new things and doing project spikes. See branches.
2
star
42

master

Starting points for software development. I am slowly migrating this functionality into my "apro" rubigen package. See branches.
2
star
43

apro

rubigen components for my projects (and perhaps your projects as well)
Objective-C
2
star
44

lightning-select

Randomizer for choosing lightning talk speakers
HTML
2
star
45

gitpod-template-elm

An Elm template for Gitpod (www.gitpod.io)
Elm
2
star
46

xadisk

Mirror of XADisk - Transaction with File Systems in Java
Java
2
star
47

socketactor

SocketChannel facade for actor frameworks
Java
2
star
48

atom-elm-format

2
star
49

elm-dlang

WIP
Haskell
2
star
50

avh4-util

Useful things for Java
Java
2
star
51

website-templates

Design/layout templates for web pages.
2
star
52

netbeans-junit-example

A simple example project of using junit from NetBeans 6.1
Java
2
star
53

uilayer

A scenegraph GUI framework designed for easy, robust automated UI testing with backends for Android, Swing and iOS.
Java
2
star
54

avh4.github.com

My github pages repository
2
star
55

literate-ruby

A new way of writing ruby apps based on Donald Knuth's Literate Programming
Ruby
2
star
56

google-toolbox-for-mac

Google toolbox for mac (SVN repo mirror)
Objective-C
2
star
57

xcodeproj-reader

vaporware - will allow reading (and eventually writing) of Xcode project files
Ruby
2
star
58

mp3-my-oggs

A command-line script to convert ogg files to mp3 files while maintaining all the file metadata, developed using BDD with cucumber
Ruby
2
star
59

ukulele-songbook

Java
1
star
60

wire-game

network topology game in Elm
Elm
1
star
61

lisp-parser

LISP parser for Java
Java
1
star
62

elm-wiki

Experiment in elm inspired by fedwiki
Elm
1
star
63

geometry

Java
1
star
64

outlin

Elm
1
star
65

elm-branches

Elm
1
star
66

tcheatsheats

JavaScript
1
star
67

robot-factory

Java
1
star
68

Schwarzwald

Fast, stable integration testing for OS X
C++
1
star
69

deft

An experimental API design for functional GUI development.
Clojure
1
star
70

elm-typist

typing tutor
Elm
1
star
71

cukes.info

Source for http://cukes.info
JavaScript
1
star
72

hde

Happy Development Environment
Java
1
star
73

platform

Ruby
1
star
74

lifeline-galaxy

Java
1
star
75

paper-less

LESS (CSS) styles for components and patterns in the Google Material Design ("Paper") style guide
CSS
1
star
76

phpfundthermo

Fork of http://sourceforge.net/projects/phpfundthermo/
PHP
1
star
77

madlibs

Java
1
star
78

avh4_soloist

Mac OSX workstation setup
1
star
79

rectified

Simple, expressive, and programmer-friendly UI design
Java
1
star
80

glucose_plot

Python
1
star
81

home

Home directory (mainly dotfiles)
Shell
1
star
82

imagecomparison-clj

Tools for comparing images and writing image-based approval tests.
Clojure
1
star
83

platform-java

Java
1
star
84

elm-elm

Elm AST in Elm
Elm
1
star
85

java-1.6-archetype

DEPRECATED -- Please use https://github.com/archetypes/java-1.6 instead
1
star
86

picard-recordingdate

MusicBrainz Picard plugin for recording date metadata
Python
1
star
87

elm-mind-map

Elm
1
star
88

avh4_workstation

Chef cookbook for workstation setup (See also pivotal/pivotal_workstation)
Ruby
1
star
89

structstore-osx

Objective-C
1
star
90

statistics-simulator

Chrome extension for keeping it real... maybe too real
JavaScript
1
star
91

check-all

Ad-hoc build tool for rapid TDD
Nix
1
star
92

platform-docs

1
star
93

project_lint

Keep your projects up to date
Ruby
1
star
94

sandbox

Create and manage temporary folders to simplify integration testing
Java
1
star
95

wysiwyg-editor-toolkit

Elm
1
star
96

codejam-bowls

Java
1
star
97

elm-persistent-data

(WIP) experimental framework for building Elm apps with user-owned data persistence
Elm
1
star
98

elm-number-format

Number formatting
Elm
1
star
99

setup

Shell scripts for setting up computers the way I like them
Shell
1
star