• Stars
    star
    439
  • Rank 95,508 (Top 2 %)
  • Language
    Elixir
  • License
    Apache License 2.0
  • Created over 7 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

🌸 An opinionated Elixir source code formatter

Circle CI Hex version API Docs Licence

exfmt 🌸

This tool has been deprecated

With the new formatter in Elixir v1.6 there is no need for this formatter any more. Thanks for checking out exfmt, it's been fun. :)

Intro

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

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 format 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:

  • 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.

Contents

Usage

mix exfmt path/to/file.ex

Command line options

  • --check - Check if file is formatted, sets exit status to 1 if false.
  • --stdin - Read from STDIN instead of a file.
  • --unsafe - Disable the semantics check that verifies that exmft has not altered the semantic meaning of the input file.

Installation

exfmt makes use of Elixir compiler features coming in Elixir v1.6.0 and as a result can only be run with Elixir v1.6-dev off the Elixir master branch, which you will need to download and compile yourself. Use with earlier versions may work without crashing, but the output format will be incorrect.

An easier method of installation will be available when Elixir v1.6.0 is released. Or sooner, perhaps!

Editor integration

Atom

Atom users can install Ron Green's 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']

Visual Studio Code

VSCode users can use exfmt with James Hrisho's vscode-exfmt package.

More Repositories

1

mix-test.watch

🎠 Because TDD is awesome
Elixir
867
star
2

dogma

🔐 A code style linter for Elixir
Elixir
472
star
3

sonic-pi-tool

🎻 Controlling Sonic Pi from the command line
Rust
200
star
4

thoas

A blazing fast JSON parser and generator in pure Erlang.
Erlang
130
star
5

rustexp

A Rust regular expression editor and tester that runs entirely within the browser!
Rust
109
star
6

elixre

🦑 An Elixir regular expression editor & tester, with Elm
Elm
101
star
7

icalendar

🗓️ A small library for reading and writing ICalendar files.
Elixir
94
star
8

yesql

An Elixir library for using SQL.
Elixir
76
star
9

purescript-aws-lambda-express

PureScript
22
star
10

wisp

Gleam
20
star
11

sqlight

💡 Use SQLite from Gleam!
Gleam
19
star
12

clint

🏚️ Nothing to see here.
Elixir
19
star
13

learning

Elixir
16
star
14

total

Basic exhaustiveness checking of unions in Elixir
Elixir
15
star
15

puter

Setting up a computer is annoying so let's automate it.
Ruby
14
star
16

soup

A simple interpreted language written in Elixir
Elixir
14
star
17

plug-redirect

A plug builder for redirecting requests.
Elixir
13
star
18

temporary-env

A tool for managing application environment state within tests.
Elixir
11
star
19

gleeunit

Gleam bindings for the Erlang EUnit test framework
Erlang
11
star
20

gleam-cloudflare-worker

JavaScript
10
star
21

nerf

Gleam bindings to gun, the Erlang HTTP/1.1, HTTP/2 and Websocket client
Gleam
9
star
22

generative-elm

Exploring Matt Pearson's "Generative Art" book, with Elm!
Elm
9
star
23

exercism

Because problems are fun.
Elixir
9
star
24

erlcaml

Erlang
8
star
25

gleam_sendgrid

A client for the SendGrid transactional email API
Gleam
8
star
26

tetromino

A little game of Tetris!
Rust
7
star
27

ecoji

Base64 is so 1999, isn't there something better?
Rust
6
star
28

linux-audio-interface-compatibility

6
star
29

elm-hearts

Inspired by the 1998 intro of the Powerpuff Girls <3
Elm
6
star
30

action

Gleam
5
star
31

lpil

Code monkey monorepo trinkets
Elixir
5
star
32

glance

Gleam
5
star
33

latex-templates

Because words are hard, and MS Word is terrible
TeX
4
star
34

elixir-aws-lambda

JavaScript
4
star
35

advent-of-code

Rust
4
star
36

dotfiles

Magic!
Shell
4
star
37

epgsql

Rust
4
star
38

htmb

Gleam
4
star
39

decksterity

A thingy for DJ me
Rust
4
star
40

gh-counts

How many Gleam projects are there?
Erlang
4
star
41

antigone

Argon2 password hashing for Gleam.
Gleam
4
star
42

cymbal

Build YAML in Gleam!
Gleam
4
star
43

purescript-format

Haskell
3
star
44

serverless-static-site

JavaScript
3
star
45

beam-lisp

Erlang
3
star
46

talk-slides

https://lpil.github.io/talk-slides/
HTML
3
star
47

osc

Because I want to learn about OSC and handling binaries in Elixir.
Elixir
3
star
48

stepper

A little JS step sequencer
JavaScript
3
star
49

formal

Gleam
3
star
50

justin

Gleam
3
star
51

exception

Gleam
2
star
52

llvm

Louis' Little Virtual Machine
Rust
2
star
53

phoenix-webpack-example

CSS
2
star
54

rust-stepper

Rust
2
star
55

kent-erlang-mooc

Erlang
2
star
56

kalimba-tabs

Elm
2
star
57

crisp

A Rusty Lisp
Rust
2
star
58

archive

Elixir
2
star
59

99-bottles-of-oop

Ruby
2
star
60

logging

Erlang
2
star
61

glue

🩹 Generate functions from your Gleam code!
Gleam
2
star
62

xcss-crystal

Abandoned, see the README
Crystal
2
star
63

zeptomail

A client for the Zeptomail transactional email API
Gleam
2
star
64

life

Conway's game of life in various languages.
Rust
2
star
65

palette

A useless library that does stuff the standard library does better.
Elixir
2
star
66

gleam-elixir-london-preview

Rust
1
star
67

waive-website

HTML
1
star
68

ka-li-da-scope

JavaScript
1
star
69

joy

Gleam
1
star
70

reddit-css

Stylesheets for various subreddits -
CSS
1
star
71

roman-numerals

Convert numbers to Roman numerals and back.
Elixir
1
star
72

gleam-test-ci-project

Erlang
1
star
73

nice-button

JavaScript
1
star
74

i3-conf

My 'puter. Tiling is fun.
Perl
1
star
75

lans-syn

Because the ANS synth is cool.
Clojure
1
star
76

natter

Elixir
1
star
77

photobank

An app for sharing photos!
Elixir
1
star
78

pushover-error-logger

An Erlang/OTP logger handler that sends error logs to Pushover
Erlang
1
star
79

elm-against-humanity

https://lpil.uk/elm-against-humanity
Elm
1
star
80

a-blog

CSS
1
star
81

learn-you-some-elixir

CSS
1
star
82

find_my_primes

Elixir
1
star
83

jot

Gleam
1
star
84

access

Clojure
1
star
85

openbox-conf

My openbox desktop config
Shell
1
star
86

my-first-code

HTML
1
star
87

purescript-datastore

PureScript
1
star
88

elixir-jot

Slightly more fun than HTML
Elixir
1
star
89

beecrypt

🐝 Buzzing Gleam bindings to the Erlang bcrypt hashing library
Gleam
1
star
90

vim2hs-flexible

Vim Script
1
star
91

prismic_ecto

An Ecto adapter for the Prismic.io CMS
Elixir
1
star
92

ex-unit-pride

Run your tests with pride.
Elixir
1
star
93

javascript-dom-parser

Gleam
1
star
94

spinner

Gleam
1
star
95

cheep

Because graphical programming is no fun.
Ruby
1
star
96

envoy

📂 A zero dependency cross platform Gleam package for reading environment variables
Gleam
1
star
97

cgi

Gleam
1
star
98

youid

Gleam
1
star