diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d7a5531..8682083e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,7 @@ The format is based on [Keep a Changelog]. calling major-mode. Also includes setting for `indent-tabs-mode` ([#286]). * [Formatter scripts](scripts/formatters) will now work on Windows if Emacs can find the executable defined in the shebang. +* `.heex` files are now properly formatted ([#304]). ### Internal * Major internal refactoring has occurred to make it possible to write @@ -50,6 +51,7 @@ The format is based on [Keep a Changelog]. [#285]: https://github.com/radian-software/apheleia/issues/285 [#290]: https://github.com/radian-software/apheleia/pull/290 [#302]: https://github.com/radian-software/apheleia/issues/302 +[#304]: https://github.com/radian-software/apheleia/pull/304 ## 4.1 (released 2024-02-25) ### Enhancements diff --git a/apheleia-formatters.el b/apheleia-formatters.el index 6257e093..0da660b7 100644 --- a/apheleia-formatters.el +++ b/apheleia-formatters.el @@ -91,7 +91,8 @@ (ktlint . ("ktlint" "--log-level=none" "--stdin" "-F" "-")) (latexindent . ("latexindent" "--logfile=/dev/null")) (mix-format . ("apheleia-from-project-root" - ".formatter.exs" "mix" "format" "-")) + ".formatter.exs" "mix" "format" + "--stdin-filename" filepath "-")) (nixfmt . ("nixfmt")) (ocamlformat . ("ocamlformat" "-" "--name" filepath "--enable-outside-detected-project")) @@ -320,6 +321,7 @@ rather than using this system." (graphql-mode . prettier-graphql) (haskell-mode . brittany) (hcl-mode . hclfmt) + (heex-ts-mode . mix-format) (html-mode . prettier-html) (html-ts-mode . prettier-html) (java-mode . google-java-format) diff --git a/test/formatters/installers/mix-format.bash b/test/formatters/installers/mix-format.bash index f09283d4..427e7ca9 100644 --- a/test/formatters/installers/mix-format.bash +++ b/test/formatters/installers/mix-format.bash @@ -1 +1,3 @@ +add-apt-repository ppa:rabbitmq/rabbitmq-erlang +apt-get update -y apt-get install -y elixir diff --git a/test/formatters/samplecode/mix-format/in.erl b/test/formatters/samplecode/mix-format/in.ex similarity index 100% rename from test/formatters/samplecode/mix-format/in.erl rename to test/formatters/samplecode/mix-format/in.ex diff --git a/test/formatters/samplecode/mix-format/in.html.heex b/test/formatters/samplecode/mix-format/in.html.heex new file mode 100644 index 00000000..a5e7683b --- /dev/null +++ b/test/formatters/samplecode/mix-format/in.html.heex @@ -0,0 +1,6 @@ +<.component id={ @a }> + <:slot attr={@b} +foo="bar"> + <%= @c %> + + diff --git a/test/formatters/samplecode/mix-format/out.erl b/test/formatters/samplecode/mix-format/out.ex similarity index 100% rename from test/formatters/samplecode/mix-format/out.erl rename to test/formatters/samplecode/mix-format/out.ex diff --git a/test/formatters/samplecode/mix-format/out.html.heex b/test/formatters/samplecode/mix-format/out.html.heex new file mode 100644 index 00000000..0fe0025d --- /dev/null +++ b/test/formatters/samplecode/mix-format/out.html.heex @@ -0,0 +1,5 @@ +<.component id={@a}> + <:slot attr={@b} foo="bar"> + <%= @c %> + +