saleyn

saleyn

ExAlign – a Mix formatter plugin that column-aligns Elixir code

Hi everyone! I’d like to share ExAlign, a new Mix formatter plugin that adds
gofmt style column alignment on top of the standard Elixir formatter.

It’s aimed at having better code readability compared to the standard “opinionated” formatter. There is no claim that one is better than another - code formatting has always been a matter of a personal taste.

Source code: https://github.com/saleyn/exalign
Documentation: https://hexdocs.pm/exalign

What it does

ExAlign runs as a formatter plugin pass after Code.format_string!, so you keep
all standard Elixir style rules and get vertical alignment layered on top. It aligns
consecutive lines that share the same indentation and pattern:

Keyword lists / struct fields

%User{
  name:       "Alice",
  age:        30,
  occupation: "developer"
}

Variable assignments

x              = 1
foo            = "bar"
something_long = 42

Module attributes

@name            “Alice”
@version         “1.0.0”
@default_timeout 5_000

Macro calls (e.g. Ecto schema fields, NimbleCSV field definitions)

field :reservation_code, function: &extract_reservation_code/1
field :guest_name,       function: &extract_guest_name/1
field :check_in_date,    function: &extract_check_in_date/1

Macro names are auto-detected - no manual locals_without_parens config needed
for aligned groups.

Arrow-clause collapsing - short -> arms are collapsed back to one line when
they fit within line_length:

case result do
  {:ok, value}      -> value
  {:error, _} = err -> err
end

Standalone CLI

There’s also a self-contained exalign escript (no Mix project needed) available
on the GitHub releases page

Feedback and contributions very welcome! The contribution guide requires a fixture
pair (input + expected output) alongside any formatting behavior change, which keeps
the test suite honest.

https://github.com/saleyn/exalign

Where Next?

Popular in Announcing Top

tmbb
PhoenixWS - Websockets over Phoenix Channels Source code on Github here: GitHub - tmbb/phoenix_ws: Websockets implemented over Phoenix Ch...
New
mathieuprog
Hello :waving_hand: Allow me to introduce you to Tz, an alternative time zone database support to Tzdata. Why another library? First a...
New
josevalim
Hi everyone, We would like to announce that Plataformatec is working on a new MySQL driver called MyXQL. Our goal is to eventually integ...
New
josevalim
EDIT: since Ecto 3.0 final version is out, this post was amended to use the final versions in the instructions below. Hi everyone, We a...
New
Crowdhailer
I have been updating a library that allows you to pipe between functions that use the erlang result tuple convention. Assuming you have ...
New
kelvinst
Hey everyone! Well, we made this lib a while ago and now we decided to finally go out and public with it! It’s a tool for creating and m...
New
tmbb
I’ve been working on two packages (not on hex.pm yet) to build admin interfaces for phoenix apps: bureaucrat - which contains a bunch ...
New
aditya7iyengar
Rummage.Ecto and Rummage.Phoenix provide ways to perform Searching, Sorting and Pagination over Ecto queries and Phoenix collections. Fo...
New
michalmuskala
Another small library today. PersistentEts Hex: persistent_ets | Hex GitHub: GitHub - michalmuskala/persistent_ets · GitHub Ets table ...
New
achempion
Hi, I would like to tell about my initiative to further maintain and develop Waffle project which is the fork of Arc library. The progre...
New

Other popular topics Top

vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New
komlanvi
Hi everyone, I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New

We're in Beta

About us Mission Statement