mirror of
https://github.com/c-cube/linol.git
synced 2026-05-05 08:54:26 -04:00
Compare commits
No commits in common. "83399e55c1c60020ea779a784d8824bc5c06bf1d" and "c6e84391e7b14e4f76ec8d183d5b683aef01dbb9" have entirely different histories.
83399e55c1
...
c6e84391e7
13 changed files with 73 additions and 71 deletions
17
.github/workflows/format.yml
vendored
17
.github/workflows/format.yml
vendored
|
|
@ -1,17 +0,0 @@
|
|||
name: format
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
format:
|
||||
name: format
|
||||
runs-on: ubuntu-latest
|
||||
container: ghcr.io/c-cube/c-cube-commmon/ci-4.14:latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- run: opam exec -- make format-check
|
||||
13
.github/workflows/gh-pages.yml
vendored
13
.github/workflows/gh-pages.yml
vendored
|
|
@ -8,13 +8,18 @@ on:
|
|||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
container: ghcr.io/c-cube/c-cube-commmon/ci-doc-5.3:latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions/checkout@main
|
||||
with:
|
||||
submodules: 'recursive'
|
||||
- uses: ocaml/setup-ocaml@v3
|
||||
with:
|
||||
ocaml-compiler: '5.2'
|
||||
dune-cache: true
|
||||
allow-prerelease-opam: true
|
||||
|
||||
- name: Deps
|
||||
run: opam install linol linol-lwt
|
||||
run: opam install odig linol linol-lwt
|
||||
|
||||
- name: Build
|
||||
run: opam exec -- odig odoc --cache-dir=_doc/ linol linol-lwt || (odig log -e ; exit 1)
|
||||
|
|
|
|||
43
.github/workflows/main.yml
vendored
43
.github/workflows/main.yml
vendored
|
|
@ -6,25 +6,52 @@ on:
|
|||
pull_request:
|
||||
jobs:
|
||||
build4:
|
||||
runs-on: ubuntu-latest
|
||||
container: ghcr.io/c-cube/c-cube-commmon/ci-4.14:latest
|
||||
strategy:
|
||||
matrix:
|
||||
os:
|
||||
- ubuntu-latest
|
||||
ocaml-compiler:
|
||||
- 4.14.x
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions/checkout@main
|
||||
with:
|
||||
submodules: 'recursive'
|
||||
- uses: ocaml/setup-ocaml@v3
|
||||
with:
|
||||
ocaml-compiler: ${{ matrix.ocaml-compiler }}
|
||||
dune-cache: true
|
||||
allow-prerelease-opam: true
|
||||
- run: opam pin -n .
|
||||
- run: opam depext -yt linol linol-lwt
|
||||
- run: opam install linol linol-lwt --deps-only -t
|
||||
- run: opam exec -- dune build -p linol,linol-lwt
|
||||
- run: opam exec -- dune runtest -p linol,linol-lwt
|
||||
|
||||
if: ${{ matrix.os == 'ubuntu-latest' }}
|
||||
build5:
|
||||
runs-on: ubuntu-latest
|
||||
container: ghcr.io/c-cube/c-cube-commmon/ci-5.4:latest
|
||||
strategy:
|
||||
matrix:
|
||||
os:
|
||||
- ubuntu-latest
|
||||
#- macos-latest
|
||||
#- windows-latest
|
||||
ocaml-compiler:
|
||||
- 5.1.x
|
||||
- 5.2.x
|
||||
- 5.3.x
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions/checkout@main
|
||||
with:
|
||||
submodules: 'recursive'
|
||||
submodules: 'recursive'
|
||||
- uses: ocaml/setup-ocaml@v3
|
||||
with:
|
||||
ocaml-compiler: ${{ matrix.ocaml-compiler }}
|
||||
dune-cache: true
|
||||
allow-prerelease-opam: true
|
||||
- run: opam pin -n .
|
||||
- run: opam depext -yt linol linol-lwt linol-eio
|
||||
- run: opam install -t . --deps-only
|
||||
- run: opam exec -- dune build
|
||||
- run: opam exec -- dune runtest
|
||||
if: ${{ matrix.os == 'ubuntu-latest' }}
|
||||
|
|
|
|||
|
|
@ -3,9 +3,6 @@
|
|||
|
||||
- breaking: the Eio library now needs the output channel to be paired with
|
||||
an `Eio.Mutex.t` to prevent race conditions (#58)
|
||||
- Allow request handlers to return Response.Errors
|
||||
- bring back `Linol_eio.spawn` for logging uncaught exceptions
|
||||
- Make template-eio handle requests concurrently
|
||||
|
||||
# 0.10
|
||||
|
||||
|
|
|
|||
5
Makefile
5
Makefile
|
|
@ -13,12 +13,9 @@ clean:
|
|||
doc:
|
||||
@dune build @doc
|
||||
|
||||
format:
|
||||
fmt:
|
||||
@dune build @fmt --auto-promote
|
||||
|
||||
format-check:
|
||||
@dune build $(DUNE_OPTS) @fmt --display=quiet
|
||||
|
||||
update-submodules:
|
||||
@git submodule update --init
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
(name linol)
|
||||
|
||||
(version 0.11)
|
||||
(version 0.10)
|
||||
|
||||
(license MIT)
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
actually meaningfully interpret and respond to.
|
||||
*)
|
||||
class lsp_server ~(sw : Eio.Switch.t) =
|
||||
class lsp_server ~(sw: Eio.Switch.t) =
|
||||
object (self)
|
||||
inherit Linol_eio.Jsonrpc2.server
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# This file is generated by dune, edit dune-project instead
|
||||
opam-version: "2.0"
|
||||
version: "0.11"
|
||||
version: "0.10"
|
||||
synopsis: "LSP server library (with Eio for concurrency)"
|
||||
maintainer: ["Simon Cruanes"]
|
||||
authors: ["Nick Hu"]
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# This file is generated by dune, edit dune-project instead
|
||||
opam-version: "2.0"
|
||||
version: "0.11"
|
||||
version: "0.10"
|
||||
synopsis: "LSP server library (with Lwt for concurrency)"
|
||||
maintainer: ["Simon Cruanes"]
|
||||
authors: ["Simon Cruanes"]
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# This file is generated by dune, edit dune-project instead
|
||||
opam-version: "2.0"
|
||||
version: "0.11"
|
||||
version: "0.10"
|
||||
synopsis: "LSP server library"
|
||||
maintainer: ["Simon Cruanes"]
|
||||
authors: ["Simon Cruanes"]
|
||||
|
|
|
|||
|
|
@ -54,11 +54,12 @@ end
|
|||
(** Spawn function. *)
|
||||
let spawn ~sw f =
|
||||
Eio.Fiber.fork ~sw (fun () ->
|
||||
try f ()
|
||||
with exn ->
|
||||
Printf.eprintf "uncaught exception in `spawn`:\n%s\n%!"
|
||||
(Printexc.to_string exn);
|
||||
raise exn)
|
||||
try
|
||||
f ()
|
||||
with exn ->
|
||||
Printf.eprintf "uncaught exception in `spawn`:\n%s\n%!"
|
||||
(Printexc.to_string exn);
|
||||
raise exn)
|
||||
|
||||
include Lsp.Types
|
||||
include IO_eio
|
||||
|
|
|
|||
|
|
@ -228,7 +228,10 @@ module Make (IO : IO) : S with module IO = IO = struct
|
|||
| Ok reply ->
|
||||
let reply_json = Lsp.Client_request.yojson_of_result r reply in
|
||||
Jsonrpc.Response.ok id reply_json
|
||||
| Error err -> Jsonrpc.Response.error id err
|
||||
| Error message ->
|
||||
Jsonrpc.Response.error id
|
||||
(Jsonrpc.Response.Error.make
|
||||
~code:Jsonrpc.Response.Error.Code.InternalError ~message ())
|
||||
in
|
||||
|
||||
send_response self response
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ module Make (IO : IO) = struct
|
|||
server_request:send_request ->
|
||||
id:Req_id.t ->
|
||||
'a Lsp.Client_request.t ->
|
||||
('a, Jsonrpc.Response.Error.t) result IO.t
|
||||
('a, string) result IO.t
|
||||
(** Method called to handle client requests.
|
||||
@param notify_back
|
||||
an object used to reply to the client, send progress messages,
|
||||
|
|
@ -379,31 +379,21 @@ module Make (IO : IO) = struct
|
|||
server_request:_ ->
|
||||
id:Req_id.t ->
|
||||
r Lsp.Client_request.t ->
|
||||
(r, Jsonrpc.Response.Error.t) result IO.t =
|
||||
(r, string) result IO.t =
|
||||
fun ~notify_back ~server_request ~id (r : _ Lsp.Client_request.t) ->
|
||||
Trace.with_span ~__FILE__ ~__LINE__ "linol.on-request"
|
||||
@@ fun _sp : (r, Jsonrpc.Response.Error.t) result IO.t ->
|
||||
@@ fun _sp : (r, string) result IO.t ->
|
||||
(* handler to catch all errors *)
|
||||
let try_catch :
|
||||
(unit -> (r, Jsonrpc.Response.Error.t) result IO.t) ->
|
||||
(r, Jsonrpc.Response.Error.t) result IO.t =
|
||||
let try_catch : (unit -> (r, _) result IO.t) -> (r, _) result IO.t =
|
||||
fun f ->
|
||||
IO.catch f (fun (exn : exn) bt ->
|
||||
match exn with
|
||||
| Linol_jsonrpc.Jsonrpc.Response.Error.E e ->
|
||||
IO.return @@ Error e
|
||||
| _ ->
|
||||
let msg =
|
||||
spf "LSP request handler failed with %s\n%s"
|
||||
(Printexc.to_string exn)
|
||||
(Printexc.raw_backtrace_to_string bt)
|
||||
in
|
||||
Log.err (fun k -> k "%s" msg);
|
||||
IO.return
|
||||
@@ Error
|
||||
(Jsonrpc.Response.Error.make
|
||||
~code:Jsonrpc.Response.Error.Code.InternalError
|
||||
~message:msg ()))
|
||||
IO.catch f (fun exn bt ->
|
||||
let msg =
|
||||
spf "LSP request handler failed with %s\n%s"
|
||||
(Printexc.to_string exn)
|
||||
(Printexc.raw_backtrace_to_string bt)
|
||||
in
|
||||
Log.err (fun k -> k "%s" msg);
|
||||
IO.return @@ Error msg)
|
||||
in
|
||||
|
||||
try_catch @@ fun () ->
|
||||
|
|
@ -747,8 +737,7 @@ module Make (IO : IO) = struct
|
|||
in
|
||||
|
||||
let new_doc : Lsp.Text_document.t =
|
||||
Lsp.Text_document.apply_content_changes ~version:doc.version
|
||||
old_doc c
|
||||
Lsp.Text_document.apply_content_changes old_doc c
|
||||
in
|
||||
|
||||
let new_st : doc_state =
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue