@@ -150,38 +150,43 @@ let ocamlmerlin_reason = "ocamlmerlin-reason"
150150
151151let set_diagnostics detached diagnostics doc =
152152 let uri = Document. uri doc in
153- let async send =
154- let + () =
155- task_if_running detached ~f: (fun () ->
156- let timer = Document. timer doc in
157- let * () = Lev_fiber.Timer.Wheel. cancel timer in
158- let * () = Lev_fiber.Timer.Wheel. reset timer in
159- let * res = Lev_fiber.Timer.Wheel. await timer in
160- match res with
161- | `Cancelled -> Fiber. return ()
162- | `Ok -> send () )
163- in
164- ()
165- in
166- match Document. syntax doc with
167- | Dune | Cram | Menhir | Ocamllex -> Fiber. return ()
168- | Reason when Option. is_none (Bin. which ocamlmerlin_reason) ->
169- let no_reason_merlin =
170- let message =
171- sprintf " Could not detect %s. Please install reason" ocamlmerlin_reason
153+ match Document. kind doc with
154+ | `Other -> Fiber. return ()
155+ | `Merlin _ -> (
156+ let async send =
157+ let + () =
158+ task_if_running detached ~f: (fun () ->
159+ let timer = Document. timer doc in
160+ let * () = Lev_fiber.Timer.Wheel. cancel timer in
161+ let * () = Lev_fiber.Timer.Wheel. reset timer in
162+ let * res = Lev_fiber.Timer.Wheel. await timer in
163+ match res with
164+ | `Cancelled -> Fiber. return ()
165+ | `Ok -> send () )
172166 in
173- Diagnostic. create
174- ~source: Diagnostics. ocamllsp_source
175- ~range: Range. first_line
176- ~message
177- ()
167+ ()
178168 in
179- Diagnostics. set diagnostics (`Merlin (uri, [ no_reason_merlin ]));
180- async (fun () -> Diagnostics. send diagnostics (`One uri))
181- | Reason | Ocaml ->
182- async (fun () ->
183- let * () = Diagnostics. merlin_diagnostics diagnostics doc in
184- Diagnostics. send diagnostics (`One uri))
169+ match Document. syntax doc with
170+ | Dune | Cram | Menhir | Ocamllex -> Fiber. return ()
171+ | Reason when Option. is_none (Bin. which ocamlmerlin_reason) ->
172+ let no_reason_merlin =
173+ let message =
174+ sprintf
175+ " Could not detect %s. Please install reason"
176+ ocamlmerlin_reason
177+ in
178+ Diagnostic. create
179+ ~source: Diagnostics. ocamllsp_source
180+ ~range: Range. first_line
181+ ~message
182+ ()
183+ in
184+ Diagnostics. set diagnostics (`Merlin (uri, [ no_reason_merlin ]));
185+ async (fun () -> Diagnostics. send diagnostics (`One uri))
186+ | Reason | Ocaml ->
187+ async (fun () ->
188+ let * () = Diagnostics. merlin_diagnostics diagnostics doc in
189+ Diagnostics. send diagnostics (`One uri)))
185190
186191let on_initialize server (ip : InitializeParams.t ) =
187192 let state : State.t = Server. state server in
0 commit comments