Skip to content

Commit

Permalink
Disable dune integration ahead of the 1.7 release
Browse files Browse the repository at this point in the history
Signed-off-by: Rudi Grinberg <[email protected]>
  • Loading branch information
rgrinberg committed Jun 29, 2021
1 parent ebc0905 commit c728032
Showing 1 changed file with 43 additions and 39 deletions.
82 changes: 43 additions & 39 deletions ocaml-lsp-server/src/ocaml_lsp_server.ml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ let not_supported () =
Jsonrpc.Response.Error.raise
(make_error ~code:InternalError ~message:"Request not supported yet!" ())

let enable_dune_rpc = false

let initialize_info : InitializeResult.t =
let codeActionProvider =
let codeActionKinds =
Expand Down Expand Up @@ -970,49 +972,51 @@ let start () =
Fiber.fork_and_join_unit
(fun () -> Fiber.Pool.run detached)
(fun () ->
let run_dune () =
let* (init_params : InitializeParams.t) = Server.initialized server in
let progress =
Progress.create init_params.capabilities
~report_progress:(fun progress ->
Server.notification server
(Server_notification.WorkDoneProgress progress))
~create_task:(fun task ->
Server.request server (Server_request.WorkDoneProgressCreate task))
in
let dune =
let dune' = Dune.create diagnostics progress in
dune := Some dune';
dune'
in
let* state = Dune.run dune in
let message =
match state with
| Error Binary_not_found ->
Some "Dune must be installed for project functionality"
| Error Out_of_date ->
Some
"Dune is out of date. Install dune >= 3.0 for project \
functionality"
| Ok () -> None
in
match message with
| None -> Fiber.return ()
(* We disable the warnings because dune 3.0 isn't available yet *)
| Some _ when true -> Fiber.return ()
| Some message ->
let* (_ : InitializeParams.t) = Server.initialized server in
let state = Server.state server in
task_if_running state ~f:(fun () ->
let log = LogMessageParams.create ~type_:Warning ~message in
Server.notification server (Server_notification.LogMessage log))
in
let* () =
Fiber.fork_and_join_unit
(fun () -> Server.start server)
(fun () ->
let* (init_params : InitializeParams.t) =
Server.initialized server
in
let progress =
Progress.create init_params.capabilities
~report_progress:(fun progress ->
Server.notification server
(Server_notification.WorkDoneProgress progress))
~create_task:(fun task ->
Server.request server
(Server_request.WorkDoneProgressCreate task))
in
let dune =
let dune' = Dune.create diagnostics progress in
dune := Some dune';
dune'
in
let* state = Dune.run dune in
let message =
match state with
| Error Binary_not_found ->
Some "Dune must be installed for project functionality"
| Error Out_of_date ->
Some
"Dune is out of date. Install dune >= 3.0 for project \
functionality"
| Ok () -> None
in
match message with
| None -> Fiber.return ()
(* We disable the warnings because dune 3.0 isn't available yet *)
| Some _ when true -> Fiber.return ()
| Some message ->
let* (_ : InitializeParams.t) = Server.initialized server in
let state = Server.state server in
task_if_running state ~f:(fun () ->
let log = LogMessageParams.create ~type_:Warning ~message in
Server.notification server
(Server_notification.LogMessage log)))
if enable_dune_rpc then
run_dune ()
else
Fiber.return ())
in
let* () =
Fiber.parallel_iter
Expand Down

0 comments on commit c728032

Please sign in to comment.