mirror of
https://github.com/c-cube/linol.git
synced 2026-03-13 09:06:18 -04:00
Compare commits
No commits in common. "c6e84391e7b14e4f76ec8d183d5b683aef01dbb9" and "fb49472f3461d806c097e17487c31325478740dc" have entirely different histories.
c6e84391e7
...
fb49472f34
2 changed files with 11 additions and 9 deletions
|
|
@ -37,7 +37,7 @@ let diagnostics (_state : state_after_processing) : Lsp.Types.Diagnostic.t list
|
||||||
so that users only need to override methods that they want the server to
|
so that users only need to override methods that they want the server to
|
||||||
actually meaningfully interpret and respond to.
|
actually meaningfully interpret and respond to.
|
||||||
*)
|
*)
|
||||||
class lsp_server ~(sw: Eio.Switch.t) =
|
class lsp_server =
|
||||||
object (self)
|
object (self)
|
||||||
inherit Linol_eio.Jsonrpc2.server
|
inherit Linol_eio.Jsonrpc2.server
|
||||||
|
|
||||||
|
|
@ -45,7 +45,7 @@ class lsp_server ~(sw: Eio.Switch.t) =
|
||||||
val buffers : (Lsp.Types.DocumentUri.t, state_after_processing) Hashtbl.t =
|
val buffers : (Lsp.Types.DocumentUri.t, state_after_processing) Hashtbl.t =
|
||||||
Hashtbl.create 32
|
Hashtbl.create 32
|
||||||
|
|
||||||
method spawn_query_handler f = Linol_eio.spawn ~sw f
|
method spawn_query_handler f = Linol_eio.spawn f
|
||||||
|
|
||||||
(* We define here a helper method that will:
|
(* We define here a helper method that will:
|
||||||
- process a document
|
- process a document
|
||||||
|
|
@ -82,8 +82,7 @@ class lsp_server ~(sw: Eio.Switch.t) =
|
||||||
and runs it as a task. *)
|
and runs it as a task. *)
|
||||||
let run () =
|
let run () =
|
||||||
Eio_main.run @@ fun env ->
|
Eio_main.run @@ fun env ->
|
||||||
Eio.Switch.run @@ fun sw ->
|
let s = new lsp_server in
|
||||||
let s = new lsp_server ~sw in
|
|
||||||
let server = Linol_eio.Jsonrpc2.create_stdio ~env s in
|
let server = Linol_eio.Jsonrpc2.create_stdio ~env s in
|
||||||
let task () =
|
let task () =
|
||||||
let shutdown () = s#get_status = `ReceivedExit in
|
let shutdown () = s#get_status = `ReceivedExit in
|
||||||
|
|
|
||||||
|
|
@ -52,14 +52,17 @@ module IO_eio :
|
||||||
end
|
end
|
||||||
|
|
||||||
(** Spawn function. *)
|
(** Spawn function. *)
|
||||||
let spawn ~sw f =
|
let spawn f =
|
||||||
Eio.Fiber.fork ~sw (fun () ->
|
let promise, resolver = Eio.Promise.create () in
|
||||||
try
|
(try
|
||||||
f ()
|
f ();
|
||||||
|
Eio.Promise.resolve_ok resolver ()
|
||||||
with exn ->
|
with exn ->
|
||||||
Printf.eprintf "uncaught exception in `spawn`:\n%s\n%!"
|
Printf.eprintf "uncaught exception in `spawn`:\n%s\n%!"
|
||||||
(Printexc.to_string exn);
|
(Printexc.to_string exn);
|
||||||
raise exn)
|
Eio.Promise.resolve_error resolver exn);
|
||||||
|
|
||||||
|
Eio.Promise.await_exn promise
|
||||||
|
|
||||||
include Lsp.Types
|
include Lsp.Types
|
||||||
include IO_eio
|
include IO_eio
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue