radian-software / apheleia

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

No feedback/logging when formatter command is not found in the exec-path #268

Closed ibrahima closed 7 months ago

ibrahima commented 7 months ago

Hi! Thanks for apheleia, it is really cool! I was trying to add an entry for the Ruby syntax_tree formatter. I wasn't getting any output and wasn't sure what was happening, even after setting apheleia-log-debug-info to t. I would get a log like this:

<format-buffer>: Invoking apheleia-format-buffer on #<buffer filepath.rb> with formatter (stree)
<run-formatter>: Running formatters (stree) on buffer #<buffer filepath.rb>

but nothing after this.

After looking at https://github.com/radian-software/apheleia/blob/8f512dba3ee2eabae0dbfd8289b89d54c132cb87/apheleia-formatters.el#L959 for a bit and trying out a formatter which worked, I realized that it tries to look up the executable in the exec-path but it seems like if it doesn't find the executable it doesn't log anything. I think it'd be nice if we could log something in this case so that people know what's wrong. In my case my exec-path was set to something custom for some reason (when I unset it, it changed to match my shell $PATH which is really all I wanted).

My elisp is a bit rusty but maybe I can contribute a patch to log something when this happens... in any case, I wanted to at least log a note of this somewhere in case someone else runs into this.

I'd also like to submit a patch to add support for the syntax_tree gem, although for those using prettier it's essentially the same as the prettier-ruby formatter. But I wanted to have it working for all projects and not just those that are using Prettier/JS packages so I wanted to have an entry for syntax_tree standalone.

raxod502 commented 7 months ago

Yep, makes perfect sense to me, merged your PR, thank you!