saleyn

saleyn

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? Top

Trending in Announcing Top

type1fool
WebAuthnLiveComponent WebAuthnComponents See this post about renaming the package. Passwordless authentication for Phoenix LiveView app...
New
GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
woylie
I released Doggo, a collection of unstyled Phoenix components. https://github.com/woylie/doggo Features Unstyled Phoenix components....
New
ahamez
Hi everyone, I’ve been working on this protobuf library for 3 years. We use it in the company I work for, EasyMile, to communicate with ...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
kip
I’ll shortly be launching Text, a nascent text analysis library. Current functionality In this early version (not ready for prime time) ...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
budgie
A little off-topic, but I feel like people here have a good head on their shoulders. I used to be quite good at making software. Was luc...
New
KristerV
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New
budgie
I love Elixir. It’s one of 2 programming languages I’ve ever fallen in love with. But I don’t use it anymore. Serverless was the promis...
New
bartblast
Hey folks, I just published a post about Hologram’s funding and where the project goes next - the short version: Curiosum as Main Spons...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews