Skip to content

Fixes formatter with sigils like ~H#55

Merged
JesseHerrick merged 2 commits intomainfrom
fix-formatter-with-sigils
May 1, 2026
Merged

Fixes formatter with sigils like ~H#55
JesseHerrick merged 2 commits intomainfrom
fix-formatter-with-sigils

Conversation

@JesseHerrick
Copy link
Copy Markdown
Member

@JesseHerrick JesseHerrick commented May 1, 2026

Continuation of #37 #36. I can't push to that branch, so adding the needed changes here.

  • Add sigil formatter support to the persistent BEAM formatter by wiring plugin-advertised sigils into Code.format_string!/2.
  • Keep whole-file plugin formatting scoped to plugins that explicitly match the file extension, while .ex / .exs files use Elixir formatting with sigil callbacks.
  • Add HEEX-focused regression coverage for a Phoenix.LiveView.HTMLFormatter-compatible plugin formatting both .heex files and ~H sigils inside Elixir files.

Note

Medium Risk
Updates the BEAM-side formatting flow to mix plugin sigil callbacks with core Elixir formatting and to scope whole-file plugin formatting by extension, which could subtly change formatting behavior across projects relying on plugins.

Overview
Fixes plugin-based formatting for sigils (e.g. ~H) in the persistent BEAM formatter by wiring plugin-advertised :sigils into the options passed to Code.format_string!/2.

Refactors formatting dispatch to (1) run whole-file plugin formatting only for plugins that explicitly claim the file extension, (2) otherwise run standard Elixir formatting for .ex/.exs (with sigil callbacks), and (3) leave other file types unchanged. Also centralizes stderr redirection during plugin/sigil formatting to prevent plugin IO from corrupting the stdout binary protocol.

Adds a regression test that builds a minimal Phoenix.LiveView.HTMLFormatter-compatible plugin and verifies it formats both .heex files and ~H sigils inside Elixir source.

Reviewed by Cursor Bugbot for commit 12c80c9. Bugbot is set up for automated code reviews on this repo. Configure here.

@JesseHerrick JesseHerrick merged commit 91cdce1 into main May 1, 2026
5 checks passed
@JesseHerrick JesseHerrick deleted the fix-formatter-with-sigils branch May 1, 2026 22:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant