Giter Site home page Giter Site logo

antouank / elm-format Goto Github PK

View Code? Open in Web Editor NEW

This project forked from avh4/elm-format

0.0 2.0 0.0 1.52 MB

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

License: BSD 3-Clause "New" or "Revised" License

Haskell 46.81% Batchfile 0.11% Shell 2.11% Ruby 0.10% PowerShell 0.04% Elm 26.78% JavaScript 24.06%

elm-format's Introduction

Build Status experimental latest version: 0.4.0-alpha

elm-format

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.

Usage

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

Installation (latest version: 0.4.0-alpha)

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.

For Elm 0.17

(Using this version with Elm 0.16 files will migrate them to Elm 0.17 syntax.)

For Elm 0.16

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 โš ๏ธ must use format-on-save or save file before formatting โœ… โœ… โš ๏ธ 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 Language Support โš ๏ธ 3 steps โ” TBD โŒ โ” TBD โ” TBD
VSCode Elm Format โš ๏ธ 3 steps โ” TBD โš ๏ธ requires configuration โ” TBD โ” TBD
Sublime Text ๐Ÿ† Elm Language Support โœ… 2 steps โ” TBD โœ… โ” TBD โ” TBD
JetBrains (WebStorm, etc) ๐Ÿ† Elm Language Plugin โš ๏ธ 3 steps โ” TBD โœ… โ” TBD โ” TBD

Detailed 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. Add the following to your user keymap:
[:editor.elm "ctrl-s" :save :elm-format :elm.lint]

This step needs improvement to be understandable by novice Light Table users: how does one edit the user keymap?

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. Set elm-format-on-save to t to apply elm-format on the current buffer on every save. (The setting can be changed via M-x customize-variable elm-format-on-save. Click button Toggle to change the setting and button State to activate the setting.)

elm-vim installation

  1. Install elm-format

  2. Install vim-plug (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 there is a section like this in your ~/.vimrc:

      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 Elm tools for VSCode

    ext install elm
  3. SHIFT-ALT-F will format the current file

VSCode Elm Format installation

  1. Install elm-format

  2. Install VSCode Elm Format

    ext install elm-format
  3. You can run elm-format by using the Elm: Format command

  4. You can also run elm-format whenever you save the file by adding formatOnSave: true option to your settings.json file.

Sublime Text installation

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

JetBrains installation

This is for WebStorm and other JetBrains IDEs.

  1. Install elm-format
  2. Install the Elm Language Plugin package.
  3. Add a file watcher for .elm files with the settings as shown here.

Development info

Building from source

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

Running tests

brew install shellcheck
cabal configure --enable-tests
./tests/run-tests.sh

elm-format's People

Contributors

avh4 avatar janiczek avatar eeue56 avatar danyx23 avatar ento avatar mgold avatar gyzerok avatar deadfoxygrandpa avatar marcowahl avatar benjick avatar bogdanp avatar brendanbenson avatar colinf avatar fredcy avatar garetht avatar jvoigtlaender avatar jmandzik avatar mattjbray avatar nicklawls avatar rundis avatar

Watchers

James Cloos avatar Antonios Karamitros avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.