Skip to content

Add ocamlformat-mlx for .mlx files #1528

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

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

davesnx
Copy link

@davesnx davesnx commented May 7, 2025

Small PR to format mlx files with ocamlformat-mlx.

In mlx we encourage dune fmt via dune dialects, but the lsp runs those formatters outside of dune.

(dialect
 (name mlx)
 (implementation
  (extension mlx)
  (merlin_reader mlx)
  (format
   (run ocamlformat-mlx %{input-file}))
  (preprocess
   (run mlx-pp %{input-file}))))

@davesnx davesnx changed the title Add ocamlformat mlx Add ocamlformat-mlx for .mlx files May 7, 2025
@davesnx davesnx marked this pull request as ready for review May 15, 2025 11:40
(* TODO: Unsure about this, keeping it empty for now *)
| Mlx ->
(match kind with
| Intf -> [ re; ml; mly; mll ]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| Intf -> [ re; ml; mly; mll ]
| Intf -> [ re; ml; mly; mll; mlx ]

as we want to be able to switch to .mlx from .mli if it is present

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But here we are matching on an "Mlx Intf", which is not an mli file, right ? I am not sure that case happens at all. But nothing really bad could happen from having too many of such rules...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking at the surrounding code, I thought the kind belongs to the origin, so we are on interface file and want to switch to the implementation, which can be .re, .ml, .mly, mll, and now .mlx

@@ -436,13 +440,18 @@ let get_impl_intf_counterparts m uri =
in
match Syntax.of_fname fname with
| Dune | Cram -> []
(* TODO: Unsure about this, keeping it empty for now *)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not clear what's the TODO about

@voodoos
Copy link
Collaborator

voodoos commented May 28, 2025

@davesnx I am not familiar with ocamlformat-mlx, but overall this looks correct.

However the CI is failing with a non-exhaustive pattern matching error, could you fix that ?

@davesnx
Copy link
Author

davesnx commented May 29, 2025

Embarrassing, I would push this forward. Thanks for the review @voodoos.

I wanted to test this PR manually before merging as well, is it as easy as pinning to ensure everything works or do I need something else?

@voodoos
Copy link
Collaborator

voodoos commented May 29, 2025

I wanted to test this PR manually before merging as well, is it as easy as pinning to ensure everything works or do I need something else?

I would expect so, please report if it doesn't :-)

Josef-Thorne-A and others added 2 commits July 1, 2025 12:11
…eing based on older version of ocaml-lsp-server
fixing pattern matching errors and type discrepancies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants