dune icon indicating copy to clipboard operation
dune copied to clipboard

Add command wrapping ocamlformat

Open gridbugs opened this issue 1 year ago • 8 comments
trafficstars

Adds a command dune tools exec ocamlformat which downloads and builds ocamlformat as a dev tool before running it, passing all positional arguments to the ocamlformat executable. This is intended to be run by text editors.

gridbugs avatar Sep 17 '24 09:09 gridbugs

I found an issue with this where if opam is installed but no switch is set then dune tools exec ocamlformat won't fall back to a globally-installed instance of ocamlformat. Will fix.

gridbugs avatar Sep 18 '24 01:09 gridbugs

I found an issue with this where if opam is installed but no switch is set then dune tools exec ocamlformat won't fall back to a globally-installed instance of ocamlformat. Will fix.

This is now fixed.

gridbugs avatar Sep 18 '24 08:09 gridbugs

I don't understand why the opam switch create test is failing. I can reproduce it on the main branch locally but error doesn't make sense to me based on the vendored copy of pp. In any case it's not related to this change.

gridbugs avatar Sep 18 '24 08:09 gridbugs

I think we just need to update our vendored copy of pp

rgrinberg avatar Sep 18 '24 09:09 rgrinberg

I've updated this PR to remove any fallback behaviour. Changes that extend environments to allow dev tools to call each other can come in a later change.

gridbugs avatar Oct 03 '24 10:10 gridbugs

I've updated this PR to remove any fallback behaviour. Changes that extend environments to allow dev tools to call each other can come in a later change.

The dev tools calling each other is temporary ? I wonder when we start having different versions of ocamlformat in a global cache to prevent rebuilding ocamlformat when switching on different projects, how we could deal with it.

moyodiallo avatar Oct 03 '24 11:10 moyodiallo

The dev tools calling each other is temporary ?

Why would it be temporary?

gridbugs avatar Oct 04 '24 01:10 gridbugs

I wonder when we start having different versions of ocamlformat in a global cache to prevent rebuilding ocamlformat when switching on different projects, how we could deal with it.

We'll always have the option to extend the environment of dev tools to include all the other dev tools in PATH. That's what my ocamllsp wrapper script does, but this behavour could also be built in to dune (not in this PR though).

gridbugs avatar Oct 04 '24 01:10 gridbugs

Is anything else required before this can be merged?

gridbugs avatar Oct 22 '24 05:10 gridbugs

Ah looks like it doesn't build after rebasing. Will fix.

gridbugs avatar Oct 22 '24 05:10 gridbugs

Ok I fixed the build error. Is anything else needed before this can be merged?

gridbugs avatar Oct 29 '24 04:10 gridbugs