diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index f96d7c1f..bb3f943d 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -10,7 +10,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@main - + with: + submodules: 'recursive' - uses: ocaml/setup-ocaml@v3 with: ocaml-compiler: '5.2' diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6ee99513..20ad873d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,6 +15,8 @@ jobs: runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@main + with: + submodules: 'recursive' - uses: ocaml/setup-ocaml@v3 with: ocaml-compiler: ${{ matrix.ocaml-compiler }} @@ -37,21 +39,17 @@ jobs: - 5.1.x - 5.2.x - 5.3.x - lsp-version: - - 1.19.0 - - 1.20.1 - - 1.22.0 runs-on: ${{ matrix.os }} steps: - 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 pin add jsonrpc ${{ matrix.lsp-version }} - - run: opam pin add lsp ${{ matrix.lsp-version }} - run: opam depext -yt linol linol-lwt linol-eio - run: opam install -t . --deps-only - run: opam exec -- dune build diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..32c92e0b --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "submodules/ocaml-lsp"] + path = submodules/ocaml-lsp + url = https://github.com/ocaml/ocaml-lsp.git diff --git a/Makefile b/Makefile index bc746532..7c1430d9 100644 --- a/Makefile +++ b/Makefile @@ -16,6 +16,9 @@ doc: fmt: @dune build @fmt --auto-promote +update-submodules: + @git submodule update --init + VERSION=$(shell awk '/^version:/ {print $$2}' linol.opam) update_next_tag: diff --git a/dune b/dune new file mode 100644 index 00000000..171ef1c3 --- /dev/null +++ b/dune @@ -0,0 +1 @@ +(data_only_dirs submodules) diff --git a/dune-project b/dune-project index 63a715da..0e32d563 100644 --- a/dune-project +++ b/dune-project @@ -28,17 +28,14 @@ "logs" ("trace" (>= "0.4")) - ("lsp" - (and - (>= "1.19") - (< "1.23"))) - ("jsonrpc" - (and - (>= "1.19") - (< "1.23"))) ("ocaml" (>= "4.14")) - ("odoc" :with-doc))) + ("odoc" :with-doc) + ; The following dependencies are needed for lsp, which we vendor + (uutf + (>= 1.0.2)) + (ppx_yojson_conv_lib + (>= "v0.14")))) (package (name linol-lwt) @@ -53,14 +50,6 @@ (and (>= "5.1") (< "6.0"))) - ("lsp" - (and - (>= "1.19") - (< "1.23"))) - ("jsonrpc" - (and - (>= "1.19") - (< "1.23"))) ("odoc" :with-doc))) (package @@ -78,12 +67,4 @@ (>= "1.0") (< "2.0"))) (eio_main :with-test) - ("lsp" - (and - (>= "1.19") - (< "1.23"))) - ("jsonrpc" - (and - (>= "1.19") - (< "1.23"))) ("odoc" :with-doc))) diff --git a/example/template-eio/main.ml b/example/template-eio/main.ml index 932e0cfa..88f01b3a 100644 --- a/example/template-eio/main.ml +++ b/example/template-eio/main.ml @@ -15,6 +15,8 @@ of a document are expected to be able to return. *) +module Lsp = Linol.Lsp + type state_after_processing = unit let process_some_input_file (_file_contents : string) : state_after_processing = diff --git a/example/template-lwt/main.ml b/example/template-lwt/main.ml index 42e0ea26..5e952ffb 100644 --- a/example/template-lwt/main.ml +++ b/example/template-lwt/main.ml @@ -15,6 +15,8 @@ of a document are expected to be able to return. *) +module Lsp = Linol.Lsp + type state_after_processing = unit let process_some_input_file (_file_contents : string) : state_after_processing = diff --git a/linol-eio.opam b/linol-eio.opam index 83d3460e..1156dd72 100644 --- a/linol-eio.opam +++ b/linol-eio.opam @@ -14,8 +14,6 @@ depends: [ "base-unix" "eio" {>= "1.0" & < "2.0"} "eio_main" {with-test} - "lsp" {>= "1.19" & < "1.23"} - "jsonrpc" {>= "1.19" & < "1.23"} "odoc" {with-doc} ] build: [ diff --git a/linol-lwt.opam b/linol-lwt.opam index 80530232..dc4918a1 100644 --- a/linol-lwt.opam +++ b/linol-lwt.opam @@ -13,8 +13,6 @@ depends: [ "linol" {= version} "base-unix" "lwt" {>= "5.1" & < "6.0"} - "lsp" {>= "1.19" & < "1.23"} - "jsonrpc" {>= "1.19" & < "1.23"} "odoc" {with-doc} ] build: [ diff --git a/linol.opam b/linol.opam index d0e1a816..e823ceb4 100644 --- a/linol.opam +++ b/linol.opam @@ -12,10 +12,10 @@ depends: [ "yojson" {>= "1.6"} "logs" "trace" {>= "0.4"} - "lsp" {>= "1.19" & < "1.23"} - "jsonrpc" {>= "1.19" & < "1.23"} "ocaml" {>= "4.14"} "odoc" {with-doc} + "uutf" {>= "1.0.2"} + "ppx_yojson_conv_lib" {>= "v0.14"} ] build: [ ["dune" "subst"] {pinned} diff --git a/src/common_.ml b/src/common_.ml index 78a5810a..d883a936 100644 --- a/src/common_.ml +++ b/src/common_.ml @@ -1,3 +1,5 @@ +module Lsp = Linol_lsp.Lsp +module Jsonrpc = Linol_jsonrpc.Jsonrpc module Trace = Trace_core let ( let@ ) = ( @@ ) diff --git a/src/dune b/src/dune index 965dc0be..6c66594f 100644 --- a/src/dune +++ b/src/dune @@ -3,4 +3,4 @@ (public_name linol) (private_modules log) (flags :standard -warn-error -a+8) - (libraries yojson lsp logs threads trace.core)) + (libraries yojson logs threads trace.core (re_export linol.lsp) (re_export linol.jsonrpc))) diff --git a/src/eio/dune b/src/eio/dune index 101c0a3f..8b146804 100644 --- a/src/eio/dune +++ b/src/eio/dune @@ -1,5 +1,5 @@ (library (name linol_eio) (public_name linol-eio) - (libraries eio eio.unix linol) + (libraries eio eio.unix linol linol.lsp linol.jsonrpc) (flags :standard -warn-error -a)) diff --git a/src/eio/linol_eio.ml b/src/eio/linol_eio.ml index 42b35d07..cadf4723 100644 --- a/src/eio/linol_eio.ml +++ b/src/eio/linol_eio.ml @@ -1,3 +1,7 @@ +open struct + module Lsp = Linol_lsp.Lsp +end + module type IO = Linol.IO module IO_eio : diff --git a/src/jsonrpc2.mli b/src/jsonrpc2.mli index 96c2acf6..8e129819 100644 --- a/src/jsonrpc2.mli +++ b/src/jsonrpc2.mli @@ -2,6 +2,7 @@ See {{: https://www.jsonrpc.org/specification} the spec} *) +open Common_ type json = Yojson.Safe.t module type IO = Sigs.IO diff --git a/src/linol.ml b/src/linol.ml index 334942e2..3d841d54 100644 --- a/src/linol.ml +++ b/src/linol.ml @@ -3,8 +3,16 @@ Abstraction over The "Lsp" library, to make it easier to develop LSP servers in OCaml (but not necessarily {b for} OCaml). *) + module type IO = Sigs.IO +(** {2 Re-export from vendored lsp} *) + +module Lsp = Linol_lsp.Lsp +module Jsonrpc = Linol_jsonrpc.Jsonrpc + +(** {2 Main modules} *) + module Jsonrpc2 = Jsonrpc2 module Server = Server module Blocking_IO = Blocking_IO diff --git a/src/lwt/dune b/src/lwt/dune index 109364d6..f9f58db1 100644 --- a/src/lwt/dune +++ b/src/lwt/dune @@ -1,5 +1,5 @@ (library (name linol_lwt) (public_name linol-lwt) - (libraries yojson lwt lwt.unix linol lsp jsonrpc) + (libraries yojson lwt lwt.unix linol linol.lsp linol.jsonrpc) (flags :standard -warn-error -a)) diff --git a/src/lwt/linol_lwt.ml b/src/lwt/linol_lwt.ml index 5b8b2889..1e182ed6 100644 --- a/src/lwt/linol_lwt.ml +++ b/src/lwt/linol_lwt.ml @@ -1,3 +1,7 @@ +open struct + module Lsp = Linol_lsp.Lsp +end + module type IO = Linol.IO module IO_lwt : diff --git a/submodules/ocaml-lsp b/submodules/ocaml-lsp new file mode 160000 index 00000000..aae69863 --- /dev/null +++ b/submodules/ocaml-lsp @@ -0,0 +1 @@ +Subproject commit aae6986391a8519de3da6a7a341f2bd3376e0d2f diff --git a/vendor/jsonrpc/dune b/vendor/jsonrpc/dune new file mode 100644 index 00000000..8429aec2 --- /dev/null +++ b/vendor/jsonrpc/dune @@ -0,0 +1,5 @@ +(copy_files %{project_root}/submodules/ocaml-lsp/jsonrpc/src/*.{ml,mli}) + +(library + (name linol_jsonrpc) + (public_name linol.jsonrpc)) diff --git a/vendor/lsp/dune b/vendor/lsp/dune new file mode 100644 index 00000000..8e6d1ae4 --- /dev/null +++ b/vendor/lsp/dune @@ -0,0 +1,11 @@ +(copy_files %{project_root}/submodules/ocaml-lsp/lsp/src/*.{ml,mli,mll}) + +(library + (name linol_lsp) + (public_name linol.lsp) + (libraries linol_jsonrpc ppx_yojson_conv_lib uutf yojson) + (flags :standard -open Linol_jsonrpc) + (lint + (pps ppx_yojson_conv))) + +(ocamllex uri_lexer)