Yea, I’m really not thrilled with the current state of code formatting in Julia. I’m hoping @kiranshila will get some more time to work on julafmt
in the future, but for now GitHub - domluna/JuliaFormatter.jl: An opinionated code formatter for Julia. Plot twist - the opinion is your own. seems to be the standard, and it would probably be worth supporting that.
That looks like it’s a library though, how would I use that to format a buffer? Is a wrapper script needed or something?
Yea, you’d probably want a wrapper script. https://codeberg.org/FelipeLema/julia-formatter.el seems relevant here.
That starts up a local web service, way more complex than this needs to be and definitely out of scope of apheleia
You can thank Julia’s JIT-AOT compiling + (current) lack of binary caching
Kiran’s juliafmt
would be in rust and hence fine, but it’s still in alpha ATM.
This one looks like a no-for-now then.
Are you able to offer any input on ESS? If you use it AFAICT all I need is an R formatter for that one, have a couple but I’m not sure how much that misses out
I haven’t really got any comments on that.
Would it be possible to make format-all-mode
an alias for apheleia-mode
? This would make possible for people to seamlessly transition.
Also, for Go, the formatter also needs to be updated (it uses a Lisp expression).
I don’t understand what you want from this. The package will be replaced with no interaction needed.
Using a list is fine
People may have stuff like (add-hook 'python-mode-hook #'format-all-mode)
(as hinted in the documentation). This won’t work anymore as they have to use to apheleia-mode
. But maybe this is not worth the trouble.
This is:
(set-formatter! 'gofmt
'(("%s" (if (or +format-region-p
(not (executable-find "goimports")))
"gofmt"
"goimports"))))
This is not handled by the current code (despite the comment of set-formatter!
saying otherwise) and apheleia does not know how to handle it either and tries to execute it as is.
I suppose it could be:
(set-formatter! 'gofmt
(if (or +format-region-p
(not (executable-find "goimports")))
"gofmt"
"goimports"))
Can’t imagine why, and yeah it probably is
OK well it’ll be removed anyway since it doesn’t do anything vs upstream
Yeah I found styler for R, but my understanding is the ESS module is used for other languages too.
Is just provider styler good enough?
I’ve set up the following script for R formatting (in format_stdin.sh
which is in PATH
):
#!/usr/bin/env sh
unset R_HOME
/usr/local/bin/Rscript -e "library(styler); txt <- readLines(file('stdin')); write(style_text(txt), stdout())"
And added the following to config.el
(set-formatter! 'styler '("format_stdin.sh") :modes '(ess-r-mode))