From f621c6c38cf902d3634358db48d479b40a3e49c4 Mon Sep 17 00:00:00 2001 From: Tom Conroy Date: Thu, 16 May 2024 16:15:44 -0400 Subject: [PATCH 1/9] Fix mix-format for `.heex` files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Per the documentation for `mix format`: ``` • --stdin-filename - path to the file being formatted on stdin. This is useful if you are using plugins to support custom filetypes such as .heex. Without passing this flag, it is assumed that the code being passed via stdin is valid Elixir code. Defaults to "stdin.exs". ``` --- apheleia-formatters.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apheleia-formatters.el b/apheleia-formatters.el index a96272b..8f5d313 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")) From d52d7ec981fcb4f59e0dc5fb6c7e77554c068677 Mon Sep 17 00:00:00 2001 From: Tom Conroy Date: Thu, 16 May 2024 16:21:48 -0400 Subject: [PATCH 2/9] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f03780b..aa3b420 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,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 ### Internal * Major internal refactoring has occurred to make it possible to write From 9b9b49e3e763acd92d6aa880cbf0baf91b65d00b Mon Sep 17 00:00:00 2001 From: Tom Conroy Date: Thu, 16 May 2024 16:24:03 -0400 Subject: [PATCH 3/9] lint --- apheleia-formatters.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apheleia-formatters.el b/apheleia-formatters.el index 8f5d313..94be9f7 100644 --- a/apheleia-formatters.el +++ b/apheleia-formatters.el @@ -91,7 +91,7 @@ (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 From 5731993ff6484e793d3eeecd122003b59e9d8943 Mon Sep 17 00:00:00 2001 From: Radon Rosborough Date: Fri, 17 May 2024 15:31:02 -0700 Subject: [PATCH 4/9] Update CHANGELOG.md --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aa3b420..bc6944e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,7 +30,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 +* `.heex` files are now properly formatted ([#304]). ### Internal * Major internal refactoring has occurred to make it possible to write @@ -43,6 +43,7 @@ The format is based on [Keep a Changelog]. [#286]: https://github.com/radian-software/apheleia/pull/286 [#285]: https://github.com/radian-software/apheleia/issues/285 [#290]: https://github.com/radian-software/apheleia/pull/290 +[#304]: https://github.com/radian-software/apheleia/pull/304 ## 4.1 (released 2024-02-25) ### Enhancements From 6df865476c387098ee0a00a56e347c6cdc676385 Mon Sep 17 00:00:00 2001 From: Tom Conroy Date: Mon, 20 May 2024 10:48:45 -0400 Subject: [PATCH 5/9] Get newer elixir version --- test/formatters/installers/mix-format.bash | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/formatters/installers/mix-format.bash b/test/formatters/installers/mix-format.bash index f09283d..427e7ca 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 From 4cfeb08a0f1bb2acefd94fea3a208f0e7a240469 Mon Sep 17 00:00:00 2001 From: Tom Conroy Date: Mon, 20 May 2024 11:04:03 -0400 Subject: [PATCH 6/9] Use .ex for elixir and add .html.heex files to test --- test/formatters/samplecode/mix-format/{in.erl => in.ex} | 0 test/formatters/samplecode/mix-format/in.html.heex | 6 ++++++ test/formatters/samplecode/mix-format/{out.erl => out.ex} | 0 test/formatters/samplecode/mix-format/out.html.heex | 5 +++++ 4 files changed, 11 insertions(+) rename test/formatters/samplecode/mix-format/{in.erl => in.ex} (100%) create mode 100644 test/formatters/samplecode/mix-format/in.html.heex rename test/formatters/samplecode/mix-format/{out.erl => out.ex} (100%) create mode 100644 test/formatters/samplecode/mix-format/out.html.heex 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 0000000..a5e7683 --- /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 0000000..0fe0025 --- /dev/null +++ b/test/formatters/samplecode/mix-format/out.html.heex @@ -0,0 +1,5 @@ +<.component id={@a}> + <:slot attr={@b} foo="bar"> + <%= @c %> + + From 3d15f1f1d185a3d5f912b2de6737e63a27807883 Mon Sep 17 00:00:00 2001 From: Tom Conroy Date: Mon, 20 May 2024 11:17:47 -0400 Subject: [PATCH 7/9] Try using full filename for test --- test/formatters/apheleia-ft.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/formatters/apheleia-ft.el b/test/formatters/apheleia-ft.el index 3855fe0..8ee2fb7 100755 --- a/test/formatters/apheleia-ft.el +++ b/test/formatters/apheleia-ft.el @@ -301,7 +301,7 @@ returned context." ;; this from the contents of the file so we set this to force it. (rename-buffer (file-name-nondirectory in-file)) (setq stdout-buffer (get-buffer-create - (format "*apheleia-ft-stdout-%S%s" formatter extension))) + (format "*apheleia-ft-stdout-%S%s" formatter in-file))) (with-current-buffer stdout-buffer (erase-buffer)) (if (functionp command) From 0c8753cd19a4fa94ee809ffa9dee42cdc841f6d7 Mon Sep 17 00:00:00 2001 From: Tom Conroy Date: Wed, 22 May 2024 15:01:30 -0400 Subject: [PATCH 8/9] Add formatter for heex-ts-mode --- apheleia-formatters.el | 1 + 1 file changed, 1 insertion(+) diff --git a/apheleia-formatters.el b/apheleia-formatters.el index 1741cfc..0da660b 100644 --- a/apheleia-formatters.el +++ b/apheleia-formatters.el @@ -321,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) From f124c8f93e64dbce07f28b8ef2ee6b45b7494df7 Mon Sep 17 00:00:00 2001 From: Tom Conroy Date: Wed, 22 May 2024 15:01:37 -0400 Subject: [PATCH 9/9] Revert --- test/formatters/apheleia-ft.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/formatters/apheleia-ft.el b/test/formatters/apheleia-ft.el index 8ee2fb7..3855fe0 100755 --- a/test/formatters/apheleia-ft.el +++ b/test/formatters/apheleia-ft.el @@ -301,7 +301,7 @@ returned context." ;; this from the contents of the file so we set this to force it. (rename-buffer (file-name-nondirectory in-file)) (setq stdout-buffer (get-buffer-create - (format "*apheleia-ft-stdout-%S%s" formatter in-file))) + (format "*apheleia-ft-stdout-%S%s" formatter extension))) (with-current-buffer stdout-buffer (erase-buffer)) (if (functionp command)