Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions dune-project
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ possible and does not make any assumptions about IO.
(jsonrpc (= :version))
(re (>= 1.5.0))
(ppx_yojson_conv_lib (>= "v0.14"))
(dune-rpc (>= 3.4.0))
(dune-rpc (>= 3.22.0))
(chrome-trace (>= 3.3.0))
dyn
stdune
(stdune (>= 3.22.0))
(fiber (and (>= 3.1.1) (< 4.0.0)))
(ocaml (and (>= 5.4) (< 5.5)))
xdg
ordering
dune-build-info
(dune-build-info (>= 3.22.0))
spawn
astring
camlp-streams
Expand Down
20 changes: 10 additions & 10 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions ocaml-lsp-server.opam
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ depends: [
"jsonrpc" {= version}
"re" {>= "1.5.0"}
"ppx_yojson_conv_lib" {>= "v0.14"}
"dune-rpc" {>= "3.4.0"}
"dune-rpc" {>= "3.22.0"}
"chrome-trace" {>= "3.3.0"}
"dyn"
"stdune"
"stdune" {>= "3.22.0"}
"fiber" {>= "3.1.1" & < "4.0.0"}
"ocaml" {>= "5.4" & < "5.5"}
"xdg"
"ordering"
"dune-build-info"
"dune-build-info" {>= "3.22.0"}
"spawn"
"astring"
"camlp-streams"
Expand Down
22 changes: 13 additions & 9 deletions ocaml-lsp-server/src/dune.ml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ module Chan : sig
type t

val create : Lev_fiber_csexp.Session.t -> t
val write : t -> Csexp.t list option -> unit Fiber.t
val write : t -> Csexp.t list -> unit Fiber.t
val read : t -> Csexp.t option Fiber.t
val close : t -> unit Fiber.t
val stop : t -> unit Fiber.t
val run : t -> unit Fiber.t
end = struct
Expand All @@ -43,16 +44,13 @@ end = struct
; finished : unit Fiber.Ivar.t
}

let stop t =
let close t =
let+ () = Fiber.return () in
Lev_fiber_csexp.Session.close t.session
;;

let write t sexp =
match sexp with
| None -> stop t
| Some sexp -> Lev_fiber_csexp.Session.write t.session sexp
;;
let stop = close
let write t sexp = Lev_fiber_csexp.Session.write t.session sexp

let read t =
let* read = Lev_fiber_csexp.Session.read t.session in
Expand Down Expand Up @@ -80,6 +78,12 @@ module Client =
let stream = Fiber.Stream.In.create t in
Fiber.Stream.In.parallel_iter stream ~f
;;

let collect_errors f =
let open Fiber.O in
let+ res = Fiber.collect_errors f in
Result.map_error res ~f:(List.map ~f:(fun (exn: Exn_with_backtrace.t) -> exn.exn))
;;
end)
(Chan)

Expand Down Expand Up @@ -470,10 +474,10 @@ end = struct
Fiber.Ivar.fill finish ())
; (let init =
let id =
Drpc.Id.make
Drpc.Request.Id.make
(List [ Atom "ocamllsp"; Atom (Int.to_string (Id.to_int running.id)) ])
in
Drpc.Initialize.create ~id
Drpc.Request.Initialize.create ~id
in
let where =
match where with
Expand Down
16 changes: 9 additions & 7 deletions ocaml-lsp-server/test/e2e-new/formatting.ml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ let write_in_file path content =
;;

let setup_ocamlformat content =
let tmpdir = Filename.temp_dir "ocamllsp-test-" "" in
let ocamlformat_path = Filename.concat tmpdir ".ocamlformat" in
let tmpdir = Stdlib.Filename.temp_file "ocamllsp-test-" "" in
Stdlib.Sys.remove tmpdir;
Unix.mkdir tmpdir 0o700;
let ocamlformat_path = Stdlib.Filename.concat tmpdir ".ocamlformat" in
write_in_file ocamlformat_path content;
tmpdir
;;
Expand Down Expand Up @@ -64,7 +66,7 @@ let%expect_test "can format an ocaml impl file" =
| _, _ -> gcd a (b mod a)
|ocaml}
in
let path = Filename.concat (setup_ocamlformat ocamlformat_config) "format_me.ml" in
let path = Stdlib.Filename.concat (setup_ocamlformat ocamlformat_config) "format_me.ml" in
print_formatting source path;
[%expect
{|
Expand All @@ -90,7 +92,7 @@ let%expect_test "leaves unchanged files alone" =
| _, _ -> gcd a (b mod a)
|ocaml}
in
let path = Filename.concat (setup_ocamlformat ocamlformat_config) "format_me.ml" in
let path = Stdlib.Filename.concat (setup_ocamlformat ocamlformat_config) "format_me.ml" in
print_formatting source path;
[%expect {| No formatting needed |}]
;;
Expand All @@ -105,7 +107,7 @@ let%expect_test "can format an ocaml intf file" =
end
|ocaml}
in
let path = Filename.concat (setup_ocamlformat ocamlformat_config) "format_me.mli" in
let path = Stdlib.Filename.concat (setup_ocamlformat ocamlformat_config) "format_me.mli" in
print_formatting source path;
[%expect
{|
Expand All @@ -132,8 +134,8 @@ let%expect_test "does not format ignored files" =
in
let tmpdir = setup_ocamlformat ocamlformat_config in
let name = "dont_format_me.ml" in
write_in_file (Filename.concat tmpdir ".ocamlformat-ignore") (name ^ "\n");
let path = Filename.concat tmpdir name in
write_in_file (Stdlib.Filename.concat tmpdir ".ocamlformat-ignore") (name ^ "\n");
let path = Stdlib.Filename.concat tmpdir name in
print_formatting source path;
[%expect {| No formatting needed |}]
;;
Loading