From 2852b6ab1eb000a7f9ecb7aa5c22d2e6fe23083a Mon Sep 17 00:00:00 2001 From: David Sancho Moreno Date: Wed, 7 May 2025 00:58:51 +0200 Subject: [PATCH 1/6] setup doesn't work, time to push --- ocaml-lsp-server/src/document.ml | 4 ++++ ocaml-lsp-server/src/ocamlformat.ml | 3 +++ ocaml-lsp-server/src/ocamlformat.mli | 3 ++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ocaml-lsp-server/src/document.ml b/ocaml-lsp-server/src/document.ml index ec1ec2956..ad532dfdb 100644 --- a/ocaml-lsp-server/src/document.ml +++ b/ocaml-lsp-server/src/document.ml @@ -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 diff --git a/ocaml-lsp-server/src/ocamlformat.ml b/ocaml-lsp-server/src/ocamlformat.ml index 28437f21f..cebdb8e91 100644 --- a/ocaml-lsp-server/src/ocamlformat.ml +++ b/ocaml-lsp-server/src/ocamlformat.ml @@ -100,8 +100,10 @@ let message = function type formatter = | Reason of Document.Kind.t | Ocaml of Uri.t + | Mlx of Uri.t let args = function + | Mlx | Ocaml uri -> [ sprintf "--name=%s" (Uri.to_path uri); "-" ] | Reason kind -> [ "--parse"; "re"; "--print"; "re" ] @@ -114,6 +116,7 @@ let args = function let binary_name t = match t with | Ocaml _ -> "ocamlformat" + | Mlx _ -> "ocamlformat-mlx" | Reason _ -> "refmt" ;; diff --git a/ocaml-lsp-server/src/ocamlformat.mli b/ocaml-lsp-server/src/ocamlformat.mli index 0d6edc6c1..186f692ba 100644 --- a/ocaml-lsp-server/src/ocamlformat.mli +++ b/ocaml-lsp-server/src/ocamlformat.mli @@ -1,6 +1,7 @@ (** Generic formatting facility for OCaml and Reason sources. - Relies on [ocamlformat] for OCaml and [refmt] for reason *) + Relies on [ocamlformat] for OCaml, [ocamlformat-mlx] for OCaml.mlx, and + [refmt] for Reason. *) open Import From 97803ab64bc2d516db73a35d3ae7476acc351dc4 Mon Sep 17 00:00:00 2001 From: David Sancho Moreno Date: Wed, 7 May 2025 01:02:35 +0200 Subject: [PATCH 2/6] run ci --- .github/workflows/build-and-test.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 61b15b91e..7c52ec38a 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -2,12 +2,6 @@ name: Build and Test on: pull_request: - push: - branches: - - master - schedule: - # Prime the caches every Monday - - cron: 0 1 * * MON jobs: build-and-test: From f796300b83af9484f8e892981467590f0df6ace5 Mon Sep 17 00:00:00 2001 From: David Sancho Moreno Date: Wed, 7 May 2025 01:41:09 +0200 Subject: [PATCH 3/6] Enable ocamlformat --- ocaml-lsp-server/src/document.ml | 4 +++- ocaml-lsp-server/src/document.mli | 1 + ocaml-lsp-server/src/ocamlformat.ml | 3 ++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ocaml-lsp-server/src/document.ml b/ocaml-lsp-server/src/document.ml index ad532dfdb..c07492cc6 100644 --- a/ocaml-lsp-server/src/document.ml +++ b/ocaml-lsp-server/src/document.ml @@ -256,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 })) ;; @@ -440,6 +440,8 @@ 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 -> [] | Ocaml -> (match kind with | Intf -> [ ml; mly; mll; eliom; re ] diff --git a/ocaml-lsp-server/src/document.mli b/ocaml-lsp-server/src/document.mli index 735bfd659..6585b6f0b 100644 --- a/ocaml-lsp-server/src/document.mli +++ b/ocaml-lsp-server/src/document.mli @@ -10,6 +10,7 @@ module Syntax : sig | Menhir | Cram | Dune + | Mlx val human_name : t -> string val markdown_name : t -> string diff --git a/ocaml-lsp-server/src/ocamlformat.ml b/ocaml-lsp-server/src/ocamlformat.ml index cebdb8e91..4d84d3aa3 100644 --- a/ocaml-lsp-server/src/ocamlformat.ml +++ b/ocaml-lsp-server/src/ocamlformat.ml @@ -103,7 +103,7 @@ type formatter = | Mlx of Uri.t let args = function - | Mlx + | Mlx uri | Ocaml uri -> [ sprintf "--name=%s" (Uri.to_path uri); "-" ] | Reason kind -> [ "--parse"; "re"; "--print"; "re" ] @@ -131,6 +131,7 @@ let formatter doc = match Document.syntax doc with | (Dune | Cram | Ocamllex | Menhir) as s -> Error (Unsupported_syntax s) | Ocaml -> Ok (Ocaml (Document.uri doc)) + | Mlx -> Ok (Mlx (Document.uri doc)) | Reason -> Ok (Reason From a4ea7888b62467458c8a268be65056fd1d4319d8 Mon Sep 17 00:00:00 2001 From: David Sancho Moreno Date: Wed, 7 May 2025 01:41:22 +0200 Subject: [PATCH 4/6] Keep ci as before --- .github/workflows/build-and-test.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 7c52ec38a..61b15b91e 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -2,6 +2,12 @@ name: Build and Test on: pull_request: + push: + branches: + - master + schedule: + # Prime the caches every Monday + - cron: 0 1 * * MON jobs: build-and-test: From 15638a3bc40b5ea8c777d16f5f3a2d08eb82bb77 Mon Sep 17 00:00:00 2001 From: David Sancho Moreno Date: Wed, 7 May 2025 01:43:53 +0200 Subject: [PATCH 5/6] Resolve doubt about get_impl_intf_counterparts --- ocaml-lsp-server/src/document.ml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/ocaml-lsp-server/src/document.ml b/ocaml-lsp-server/src/document.ml index c07492cc6..1efbf24dc 100644 --- a/ocaml-lsp-server/src/document.ml +++ b/ocaml-lsp-server/src/document.ml @@ -425,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 = @@ -441,14 +441,17 @@ let get_impl_intf_counterparts m uri = match Syntax.of_fname fname with | Dune | Cram -> [] (* TODO: Unsure about this, keeping it empty for now *) - | Mlx -> [] + | Mlx -> + (match kind with + | Intf -> [ re; ml; mly; mll ] + | Impl -> [ rei; mli; mly; mll ]) | Ocaml -> (match kind with - | Intf -> [ ml; mly; mll; eliom; re ] + | Intf -> [ ml; mly; mll; eliom; re; mlx ] | Impl -> [ mli; mly; mll; eliomi; rei ]) | Reason -> (match kind with - | Intf -> [ re; ml ] + | Intf -> [ re; ml; mlx ] | Impl -> [ rei; mli ]) | Ocamllex -> [ mli; rei ] | Menhir -> [ mli; rei ] From 0988f2b9b0ea6822ed0f8a970b7eaf807605f772 Mon Sep 17 00:00:00 2001 From: David Sancho Moreno Date: Tue, 16 Sep 2025 10:21:49 +0200 Subject: [PATCH 6/6] Add mlx as exts_to_switch_to --- ocaml-lsp-server/src/document.ml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ocaml-lsp-server/src/document.ml b/ocaml-lsp-server/src/document.ml index 1efbf24dc..e34f80784 100644 --- a/ocaml-lsp-server/src/document.ml +++ b/ocaml-lsp-server/src/document.ml @@ -440,11 +440,10 @@ 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 ] - | Impl -> [ rei; mli; mly; mll ]) + | Intf -> [ re; ml; mly; mll; mlx ] + | Impl -> [ rei; mli; mly; mll; mlx ]) | Ocaml -> (match kind with | Intf -> [ ml; mly; mll; eliom; re; mlx ]