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

woylie
Flop is an Elixir library that applies filtering, ordering and pagination parameters to your Ecto queries. offset-based pagination with...
New
MRdotB
I needed to reuse React components from my Chrome extension in my Phoenix/LiveView backend. I noticed that for Svelte/Vue, there are live...
New
woylie
I released Doggo, a collection of unstyled Phoenix components. https://github.com/woylie/doggo Features Unstyled Phoenix components....
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
anuaralfetahe
Hello Published a new library - ProcessHub! ProcessHub is a library designed to manage process distribution within the Elixir cluster. ...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
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
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
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
sergio
It’s not that it’s vocabulary is too advanced. It’s something worse. I get lost trying to follow even a paragraph written by Claude. It’...
New
AstonJ
This showed up on my feed.. anyone heard of it? Just hype? Ox Alpha is a reasoning model designed for coding, sustained ag...
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