erlalign (erlalign v0.1.4)

View Source

Erlang code formatter that applies column alignment on top of erlfmt output

ErlAlign mirrors ExAlign's functionality for Erlang source code, enabling readable column-aligned formatting similar to Go's gofmt

Summary

Functions

Align case/if arrows: Pattern -> Body

Align consecutive variable assignments: Var = value

Format Erlang source contents with column alignment Opts may include

Load global configuration from ~/.config/erlalign/.formatter.exs

Main CLI entry point. Parses arguments and runs the formatter Calls erlang:halt/1 with appropriate exit code

Set default value for trim_eol_ws option if not already set Default is true (trim trailing whitespace)

Trim trailing whitespace from all lines if trim_eol_ws option is true

Functions

align_case_arrows(Code)

Align case/if arrows: Pattern -> Body

align_comments(Code)

align_group(Lines, GetPosFun)

align_variable_assignments(Code)

Align consecutive variable assignments: Var = value

find_arrow_pos(Line)

find_balanced_close_debug(Content, Depth, InString)

find_protected_regions_debug(Line)

find_quote_close_debug(Content)

format(Contents)

Format Erlang source contents with column alignment Opts may include:

  • line_length (integer, default 98): Maximum line length for alignment
  • eol_at_eof (:add, :remove, or nil, default nil): Controls end-of-file newline handling With :add, a trailing newline is added if not present With :remove, any trailing newline is removed With nil, the end-of-file newline is left unchanged
  • keep_separators (boolean, default false):
  • trim_eol_ws (boolean, default true): When true, trim trailing whitespace from end of lines

format(Contents, Opts)

handle_eol_at_eof(Result, Opts)

init(State)

-spec init(rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()}.

load_global_config()

Load global configuration from ~/.config/erlalign/.formatter.exs

main(Args)

Main CLI entry point. Parses arguments and runs the formatter Calls erlang:halt/1 with appropriate exit code

set_default_trim_eol_ws(Opts)

Set default value for trim_eol_ws option if not already set Default is true (trim trailing whitespace)

trim_eol_whitespace(Code, Opts)

Trim trailing whitespace from all lines if trim_eol_ws option is true