From f3b9c72eb18d4f90cf4d0e1dc3e3f55a1a0080d4 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Sun, 21 Nov 2021 10:16:55 -0600 Subject: [PATCH] fix: allow disabling dune integration Signed-off-by: Rudi Grinberg --- ocaml-lsp-server/src/dune.ml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/ocaml-lsp-server/src/dune.ml b/ocaml-lsp-server/src/dune.ml index c59fced7b..243186d94 100644 --- a/ocaml-lsp-server/src/dune.ml +++ b/ocaml-lsp-server/src/dune.ml @@ -584,6 +584,17 @@ let create workspaces (client_capabilities : ClientCapabilities.t) diagnostics ; workspaces }) +let enabled = false + +let create_disabled () = ref Closed + +let create workspaces (client_capabilities : ClientCapabilities.t) diagnostics + progress ~log = + if enabled then + create workspaces client_capabilities diagnostics progress ~log + else + Fiber.return (create_disabled ()) + let run_loop t = Fiber.repeat_while ~init:() ~f:(fun () -> match !t with @@ -598,7 +609,7 @@ let run_loop t = let run t : unit Fiber.t = Fiber.of_thunk (fun () -> match !t with - | Closed -> Code_error.raise "dune already closed" [] + | Closed -> Fiber.return () | Active active -> Fiber.fork_and_join_unit (fun () -> run_loop t)