-
Notifications
You must be signed in to change notification settings - Fork 141
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
base: master
Are you sure you want to change the base?
Changes from 5 commits
2852b6a
97803ab
f796300
a4ea788
15638a3
185754d
0988f2b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -32,6 +32,7 @@ module Syntax = struct | |||||
| Menhir | ||||||
| Cram | ||||||
| Dune | ||||||
| Mlx | ||||||
|
||||||
let human_name = function | ||||||
| Ocaml -> "OCaml" | ||||||
|
@@ -40,6 +41,7 @@ module Syntax = struct | |||||
| Menhir -> "Menhir/ocamlyacc" | ||||||
| Cram -> "Cram" | ||||||
| Dune -> "Dune" | ||||||
| Mlx -> "OCaml.mlx" | ||||||
;; | ||||||
|
||||||
let all = | ||||||
|
@@ -52,6 +54,7 @@ module Syntax = struct | |||||
; "dune", Dune | ||||||
; "dune-project", Dune | ||||||
; "dune-workspace", Dune | ||||||
; "ocaml.mlx", Mlx | ||||||
] | ||||||
;; | ||||||
|
||||||
|
@@ -61,6 +64,7 @@ module Syntax = struct | |||||
| s -> | ||||||
(match Filename.extension s with | ||||||
| ".eliomi" | ".eliom" | ".mli" | ".ml" -> Ok Ocaml | ||||||
| ".mlx" -> Ok Mlx | ||||||
| ".rei" | ".re" -> Ok Reason | ||||||
| ".mll" -> Ok Ocamllex | ||||||
| ".mly" -> Ok Menhir | ||||||
|
@@ -252,7 +256,7 @@ let make wheel config pipeline (doc : DidOpenTextDocumentParams.t) ~position_enc | |||||
let tdoc = Text_document.make ~position_encoding doc in | ||||||
let syntax = Syntax.of_text_document tdoc in | ||||||
match syntax with | ||||||
| Ocaml | Reason -> make_merlin wheel config pipeline tdoc syntax | ||||||
| Ocaml | Reason | Mlx -> make_merlin wheel config pipeline tdoc syntax | ||||||
| Ocamllex | Menhir | Cram | Dune -> Fiber.return (Other { tdoc; syntax })) | ||||||
;; | ||||||
|
||||||
|
@@ -421,8 +425,8 @@ let close t = | |||||
let get_impl_intf_counterparts m uri = | ||||||
let fpath = Uri.to_path uri in | ||||||
let fname = Filename.basename fpath in | ||||||
let ml, mli, eliom, eliomi, re, rei, mll, mly = | ||||||
"ml", "mli", "eliom", "eliomi", "re", "rei", "mll", "mly" | ||||||
let ml, mli, eliom, eliomi, re, rei, mll, mly, mlx = | ||||||
"ml", "mli", "eliom", "eliomi", "re", "rei", "mll", "mly", "mlx" | ||||||
in | ||||||
let exts_to_switch_to = | ||||||
let kind = | ||||||
|
@@ -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 *) | ||||||
| Mlx -> | ||||||
(match kind with | ||||||
| Intf -> [ re; ml; mly; mll ] | ||||||
|
| 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
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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