radian-software / apheleia

🌷 Run code formatter on buffer contents without moving point, using RCS patches and dynamic programming.
MIT License
523 stars 74 forks source link

feat: add filepath to mix-format #230

Closed cepehang closed 9 months ago

cepehang commented 9 months ago

Allows mix to format files other than elixir or erlang files, e.g. .heex files given :

cepehang commented 9 months ago

The --stdin-filename option is available since mix version 1.14 but Ubuntu 20 only has mix version 1.9 in its repositories.

raxod502 commented 9 months ago

One option would be to add an apheleia-mix-format script, similar to https://github.com/radian-software/apheleia/blob/main/scripts/formatters/apheleia-phpcs, which would run mix-format --version (or equivalent) and cache the output on disk somewhere in $XDG_CACHE_HOME, invalidating that cache when the mtime of the mix-format binary is updated. Then it would either pass the argument or not, depending on the version.

That might be more effort than it's worth, though, given that you also have the opportunity to just change the formatter options directly in your init.el.