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

Elixir formatter not using project `.formatter.exs` file #232

Closed NickBoyadjian closed 8 months ago

NickBoyadjian commented 9 months ago

When formatting a file within a project that has a .formatter.exs file, apheleia is not using this config to format the file.

raxod502 commented 9 months ago

Is it expected behavior to use such a file if it's present? Can you point to some documentation that explains what Apheleia should be doing? I'm not familiar with the Elixir ecosystem.

NickBoyadjian commented 9 months ago

I definitely think that would be the expected behavior. If you check out these docs, you can see that the default is to read from the .formatter.exs file.

https://hexdocs.pm/mix/main/Mix.Tasks.Format.html

The main issue is that when saving a file, apheleia runs the "mix format" command from the directory that the current open buffer is in, rather than the project root directory.

raxod502 commented 8 months ago

Maybe something like https://github.com/radian-software/apheleia/pull/239? (I haven't tested it, I don't have an Elixir toolchain installed locally.)

NickBoyadjian commented 8 months ago

That's awesome, thank you! I just tested it in my emacs and it worked perfectly :D

raxod502 commented 8 months ago

Fantastic, merged :)