mirror of
https://github.com/c-cube/linol.git
synced 2025-12-06 03:05:31 -05:00
format code
This commit is contained in:
parent
fa8ec8ee77
commit
50cc7a9527
6 changed files with 36 additions and 24 deletions
3
Makefile
3
Makefile
|
|
@ -13,6 +13,9 @@ clean:
|
|||
doc:
|
||||
@dune build @doc
|
||||
|
||||
fmt:
|
||||
@dune build @fmt --auto-promote
|
||||
|
||||
VERSION=$(shell awk '/^version:/ {print $$2}' linol.opam)
|
||||
|
||||
update_next_tag:
|
||||
|
|
|
|||
|
|
@ -10,11 +10,9 @@ let ( let* ) x f = f x
|
|||
let ( and+ ) a b = a, b
|
||||
let return x = x
|
||||
let failwith = failwith
|
||||
|
||||
let fail = Printexc.raise_with_backtrace
|
||||
|
||||
let stdin = fun () -> stdin
|
||||
let stdout = fun () -> stdout
|
||||
let stdin () = stdin
|
||||
let stdout () = stdout
|
||||
|
||||
let default_spawn f =
|
||||
let run () =
|
||||
|
|
|
|||
|
|
@ -15,11 +15,15 @@ module IO_eio :
|
|||
let failwith = failwith
|
||||
let fail = raise
|
||||
|
||||
let catch f handler = try f () with exn ->
|
||||
let bt = Printexc.get_raw_backtrace () in
|
||||
handler exn bt
|
||||
let catch f handler =
|
||||
try f ()
|
||||
with exn ->
|
||||
let bt = Printexc.get_raw_backtrace () in
|
||||
handler exn bt
|
||||
|
||||
let stdin env =
|
||||
Eio.Buf_read.of_flow ~max_size:1_000_000 (Eio.Stdenv.stdin env)
|
||||
|
||||
let stdin env = Eio.Buf_read.of_flow ~max_size:1_000_000 (Eio.Stdenv.stdin env)
|
||||
let stdout = Eio.Stdenv.stdout
|
||||
|
||||
type env = Eio_unix.Stdenv.base
|
||||
|
|
@ -27,29 +31,28 @@ module IO_eio :
|
|||
type out_channel = Eio_unix.sink_ty Eio.Std.r
|
||||
|
||||
let write_string out_ch str = Eio.Flow.copy_string str out_ch
|
||||
|
||||
let write out_ch bytes off len =
|
||||
Eio.Buf_write.with_flow out_ch @@ fun w ->
|
||||
Eio.Buf_write.bytes w ~off ~len bytes
|
||||
|
||||
let read in_ch bytes off len =
|
||||
let str = Eio.Buf_read.take len in_ch in
|
||||
Bytes.blit_string str off bytes 0 len
|
||||
let read_line in_ch =
|
||||
Eio.Buf_read.line in_ch
|
||||
|
||||
let read_line in_ch = Eio.Buf_read.line in_ch
|
||||
end
|
||||
|
||||
(** Spawn function. *)
|
||||
let spawn f =
|
||||
let promise, resolver = Eio.Promise.create () in
|
||||
begin
|
||||
try
|
||||
f ();
|
||||
Eio.Promise.resolve_ok resolver ()
|
||||
with
|
||||
exn ->
|
||||
(Printf.eprintf "uncaught exception in `spawn`:\n%s\n%!"
|
||||
(Printexc.to_string exn));
|
||||
Eio.Promise.resolve_error resolver exn
|
||||
end;
|
||||
(try
|
||||
f ();
|
||||
Eio.Promise.resolve_ok resolver ()
|
||||
with exn ->
|
||||
Printf.eprintf "uncaught exception in `spawn`:\n%s\n%!"
|
||||
(Printexc.to_string exn);
|
||||
Eio.Promise.resolve_error resolver exn);
|
||||
|
||||
Eio.Promise.await_exn promise
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,11 @@ module type S = sig
|
|||
t
|
||||
|
||||
val create_stdio :
|
||||
?on_received:(json -> unit) -> ?on_sent:(json -> unit) -> env:IO.env -> server -> t
|
||||
?on_received:(json -> unit) ->
|
||||
?on_sent:(json -> unit) ->
|
||||
env:IO.env ->
|
||||
server ->
|
||||
t
|
||||
|
||||
val send_server_notification : t -> Lsp.Server_notification.t -> unit IO.t
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,11 @@ module type S = sig
|
|||
(** Create a connection from the pair of channels *)
|
||||
|
||||
val create_stdio :
|
||||
?on_received:(json -> unit) -> ?on_sent:(json -> unit) -> env:IO.env -> server -> t
|
||||
?on_received:(json -> unit) ->
|
||||
?on_sent:(json -> unit) ->
|
||||
env:IO.env ->
|
||||
server ->
|
||||
t
|
||||
(** Create a connection using stdin/stdout *)
|
||||
|
||||
val send_server_notification : t -> Lsp.Server_notification.t -> unit IO.t
|
||||
|
|
|
|||
|
|
@ -18,8 +18,8 @@ module IO_lwt :
|
|||
|
||||
let return = Lwt.return
|
||||
let failwith = Lwt.fail_with
|
||||
let stdin = fun () -> Lwt_io.stdin
|
||||
let stdout = fun () -> Lwt_io.stdout
|
||||
let stdin () = Lwt_io.stdin
|
||||
let stdout () = Lwt_io.stdout
|
||||
|
||||
type env = unit
|
||||
type in_channel = Lwt_io.input Lwt_io.channel
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue