:editor format refactor

First intended pass is done!

Every module listed above has been actioned in some way now, either included and tested in an isolated case, already included upstream, or crossed out due to lacking tooling support/requiring a domain expert.

Next pass will be spending a bit more time on each module (as well as checking if I’ve missed any modules that make sense to add a formatter for) and then writing install documentation for each module (as well as workarounds for any known issues/weirdness)

As it stands, this is ready for testing by whomever wants to; I’m not an expert on every language so I would have no idea about best practices in most of the modules.

And as above, if you’re a user of any module that is crossed out, please do let me know of a working linter/formatter that:

  • Accepts input from stdin
  • Sends output to stdout
  • Can be installed/used as a script/executable or at worst through arguments to a tool

TL;DR large bulk of the work is done, please test if you can

Upstream does support nix, but it’s the nixfmt formatter which isn’t used very much. The community has not yet agreed on a canonical formatter but AFAIK, nixpkgs-fmt is used far more frequently, so maybe we should add that in here for now?

Thanks for bringing that to my attention!

This is almost certainly a good candidate for an upstream change, so I’ll test it tonight and create an upstream PR (and also make the change in doom so it’s not blocked)

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.

1 Like

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 :crai:

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 :stuck_out_tongue: 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.

1 Like

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")))

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")))

Can’t imagine why, and yeah it probably is

OK well it’ll be removed anyway since it doesn’t do anything vs upstream

I’ve always used styler for R

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?