-
Notifications
You must be signed in to change notification settings - Fork 186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable formatting projects without an .ocamlformat
by default
#2092
Comments
I am still not sure this is the best, but what we could do is to also enable for the formatting if we are in one of these cases, the
This way we still have the constraint "we detect we are in a dune project" checked, we just enable it by relying on an explicit stanza in the |
I would instead suggest an opt-out instead of an opt-in. If you REALLY don't want to use formatting in your project (which is a bad idea already), then create an |
Asking for an |
having several formatter competing in a language ecosystem is really not a great situation IMO. I was imagining that if you work on a project that really doesn't want to use ocamlformat, then you'd create an |
In a given project, I agree, but in a language tooling, I don't see why. In any case, I don't see why
I think using a directive in the |
Thanks for starting the discussion and sharing your feedback @mimoo and @grayswandyr! To answer
and
This is exactly why we have the OCaml Platform. If a new formatter enters the playing ground tomorrow, it can be incubated in the Platform. No two tools that solve the same problem can exist in the Active stage of the Platform, so if the user base of this hypothetical formatter grows to the point the formatter should be in the Active stage of the Platform, we'll have to think of how to resolve this to avoid splitting the ecosystem: either by merging the tools, or by moving ocamlformat to Sustain and offer a transition path to that new formatter. FTR this is exactly the situation dune-release and opam-publish are in: dune-release is used by many users, but to move dune-release to Active, we need to figure out a way to not have two competing tools to publish opam packages. This doesn't mean that the two formatters can't be integrated in Dune at the same time, but an integration of a Incubated tool would probably be opt-in and experimental (like the integration of Mdx in Dune at the moment, which requires a |
@tmattio ok, thanks. But what is the OCaml Platform's position w.r.t. not asking users to create yet another file (an empty |
Some guiding principles to improve the user experience include having good defaults, or strong backward compatibility. In that sense I think the proposal makes sense, however, these are guiding principles that should inform the target user experience, the goal isn't to impose technical decisions on the maintainers, so it's up to the OCamlFormat maintainers to see what they want to do with this proposal. These decisions take into account user feedback, the principles of the Platform, but also the existing technical constraints: it's quite possible that introducing this change makes sense in the future but not immediately for instance. |
I believe the reason for OCamlformat to refuse to format in some cases is to support "formatting on save" in editors. Formatting on save a file that shouldn't be is potentially more annoying than OCamlformat refusing to work for obscure reasons. The current behavior is surprising and reading the
This changes the default behavior and is dangerous for users of the previous behavior, which are believe are common. |
This is a follow-up on ocaml/dune#5768 to continue the discussion on whether ocamlformat should support formatting projects without an
.ocamlformat
configuration file by default.@gpetiot mentioned in the PR above that he thinks the current behavior should be preserved.
I still wanted to provide a few arguments in favor of supporting the formatting of projects without an
.ocamlformat
file here nonetheless.One pain point that is not specific to ocamlformat that I'm hoping to alleviate with this is the number of configuration files needed to have a full development environment.
By full development environment, I mean a project where I can execute common developer workflow easily (e.g. formatting the code base).
Not requiring a configuration file for ocamlformat would remove one of these.
My understanding of why we want to enforce a configuration file is to prevent different people from formatting the code with a different version of ocamlformat. I see a few problems with enforcing the configuration file to work around that:
.ocamlformat
. We can see a lot of.ocamlformat
files in the wild that don't have this field. And so just requiring an.ocamlformat
file does not solve the above problem.And to go further, I think removing the need for an
.ocamlformat
file would improve a few scenarios:dune init
a the moment won't be able to format their code. They would have to search which formatter to use, and how to enable it. We can hope that they will stumble upon the dune formatting documentation or the best practices on ocaml.org quickly, but this will still remain a friction point for beginners.ocamlformat
, even if it provides a great degree of flexibility when it comes to the formatting configuration, doesn't encourage users to configure it. Not requiring an.ocamlformat
file would be a good way to incentivize people to use the default profile.Let me know what you think 🙂
The text was updated successfully, but these errors were encountered: