Skip to content

Commit 4eefe13

Browse files
authored
Merge pull request #702 from coq-community/coq-8.19
Coq 8.19 compatibility
2 parents 014c666 + bf48804 commit 4eefe13

File tree

13 files changed

+276
-35
lines changed

13 files changed

+276
-35
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ jobs:
2727
strategy:
2828
matrix:
2929
os: [ubuntu-latest, macos-latest]
30+
coq: [coq-8-18, coq-8-19, coq-master]
3031
runs-on: ${{ matrix.os }}
3132
steps:
3233
- name: Checkout
@@ -41,7 +42,7 @@ jobs:
4142
- uses: cachix/install-nix-action@v22
4243
with:
4344
nix_path: nixpkgs=channel:nixos-unstable
44-
- run: nix develop .#vscoq-language-server -c bash -c "cd language-server && dune build"
45+
- run: nix develop .#vscoq-language-server-${{ matrix.coq }} -c bash -c "cd language-server && dune build"
4546
- run: nix develop .#vscoq-client -c bash -c "cd client && yarn run install:all && yarn run build:all && yarn run compile"
4647
- run: xvfb-run nix develop .#vscoq-client -c bash -c "cd client && yarn test"
4748
if: runner.os == 'Linux'
@@ -52,9 +53,11 @@ jobs:
5253

5354
install-opam:
5455
strategy:
56+
fail-fast: false
5557
matrix:
5658
os: [ubuntu-latest]
5759
ocaml-compiler: [4.13.x]
60+
coq: [8.18.0, 8.19+rc1, dev]
5861
runs-on: ${{ matrix.os }}
5962
steps:
6063
- name: Checkout
@@ -70,6 +73,7 @@ jobs:
7073
OPAMYES: true
7174
run: |
7275
opam repo add coq-core-dev https://coq.inria.fr/opam/core-dev
76+
opam install coq-core.${{ matrix.coq }}
7377
opam pin add vscoq-language-server ./language-server/ --with-doc --with-test -y
7478
7579
- run: |

flake.lock

Lines changed: 57 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 109 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,88 @@
55

66
flake-utils.url = "github:numtide/flake-utils";
77

8+
coq-master = { url = "github:coq/coq/b157d65080076498ad04dd3918c1e508eb9740c0"; }; # Should be kept in sync with PIN_COQ in CI workflow
9+
coq-master.inputs.nixpkgs.follows = "nixpkgs";
10+
811
};
912

10-
outputs = { self, nixpkgs, flake-utils }:
13+
outputs = { self, nixpkgs, flake-utils, coq-master }:
1114
flake-utils.lib.eachDefaultSystem (system:
1215

16+
let coq = coq-master.defaultPackage.${system}; in
1317
rec {
1418

15-
packages.default = self.packages.${system}.vscoq-language-server;
19+
packages.default = self.packages.${system}.vscoq-language-server-coq-8-19;
20+
21+
packages.vscoq-language-server-coq-8-18 =
22+
# Notice the reference to nixpkgs here.
23+
with import nixpkgs { inherit system; };
24+
let ocamlPackages = ocaml-ng.ocamlPackages_4_14; in
25+
ocamlPackages.buildDunePackage {
26+
duneVersion = "3";
27+
pname = "vscoq-language-server";
28+
version = "2.0.3";
29+
src = ./language-server;
30+
buildInputs = [
31+
coq_8_18
32+
dune_3
33+
] ++ (with coq.ocamlPackages; [
34+
lablgtk3-sourceview3
35+
glib
36+
gnome.adwaita-icon-theme
37+
wrapGAppsHook
38+
ocaml
39+
yojson
40+
zarith
41+
findlib
42+
ppx_inline_test
43+
ppx_assert
44+
ppx_sexp_conv
45+
ppx_deriving
46+
ppx_optcomp
47+
ppx_import
48+
sexplib
49+
ppx_yojson_conv
50+
lsp
51+
sel
52+
]);
53+
};
54+
55+
packages.vscoq-language-server-coq-8-19 =
56+
# Notice the reference to nixpkgs here.
57+
with import nixpkgs { inherit system; };
58+
let ocamlPackages = ocaml-ng.ocamlPackages_4_14; in
59+
ocamlPackages.buildDunePackage {
60+
duneVersion = "3";
61+
pname = "vscoq-language-server";
62+
version = "2.0.3";
63+
src = ./language-server;
64+
buildInputs = [
65+
coq_8_19
66+
dune_3
67+
] ++ (with coq.ocamlPackages; [
68+
lablgtk3-sourceview3
69+
glib
70+
gnome.adwaita-icon-theme
71+
wrapGAppsHook
72+
ocaml
73+
yojson
74+
zarith
75+
findlib
76+
ppx_inline_test
77+
ppx_assert
78+
ppx_sexp_conv
79+
ppx_deriving
80+
ppx_optcomp
81+
ppx_import
82+
sexplib
83+
ppx_yojson_conv
84+
lsp
85+
sel
86+
]);
87+
};
1688

17-
packages.vscoq-language-server =
89+
packages.vscoq-language-server-coq-master =
1890
# Notice the reference to nixpkgs here.
1991
with import nixpkgs { inherit system; };
2092
let ocamlPackages = ocaml-ng.ocamlPackages_4_14; in
@@ -39,6 +111,7 @@
39111
ppx_assert
40112
ppx_sexp_conv
41113
ppx_deriving
114+
ppx_optcomp
42115
ppx_import
43116
sexplib
44117
ppx_yojson_conv
@@ -61,11 +134,42 @@
61134

62135
};
63136

64-
devShells.default =
137+
devShells.vscoq-client =
138+
with import nixpkgs { inherit system; };
139+
mkShell {
140+
buildInputs = self.packages.${system}.vscoq-client.buildInputs;
141+
};
142+
143+
devShells.vscoq-language-server-coq-8-18 =
144+
with import nixpkgs { inherit system; };
145+
mkShell {
146+
buildInputs =
147+
self.packages.${system}.vscoq-language-server-coq-8-18.buildInputs;
148+
};
149+
150+
devShells.vscoq-language-server-coq-8-19 =
151+
with import nixpkgs { inherit system; };
152+
mkShell {
153+
buildInputs =
154+
self.packages.${system}.vscoq-language-server-coq-8-19.buildInputs;
155+
};
156+
157+
devShells.vscoq-language-server-coq-master =
158+
with import nixpkgs { inherit system; };
159+
let ocamlPackages = ocaml-ng.ocamlPackages_4_14; in
160+
mkShell {
161+
buildInputs =
162+
self.packages.${system}.vscoq-language-server-coq-master.buildInputs
163+
++ (with ocamlPackages; [
164+
ocaml-lsp
165+
]);
166+
};
167+
168+
devShells.default =
65169
with import nixpkgs { inherit system; };
66170
mkShell {
67171
buildInputs =
68-
self.packages.${system}.vscoq-language-server.buildInputs
172+
self.packages.${system}.vscoq-language-server-coq-8-19.buildInputs
69173
++ (with ocamlPackages; [
70174
ocaml-lsp
71175
]);

language-server/dm/completionSuggester.ml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -415,13 +415,18 @@ let get_completion_items env proof lemmas options =
415415
log ("Ranking of lemmas failed: " ^ (Printexc.to_string e));
416416
lemmas
417417

418+
[%%if coq = "8.18"]
419+
let generic_search e s f = Search.generic_search e (fun r k e c -> f r k e s c)
420+
[%%else]
421+
let generic_search = Search.generic_search
422+
[%%endif]
418423
let get_lemmas sigma env =
419424
let open CompletionItems in
420425
let results = ref [] in
421-
let display ref _kind env c =
426+
let display ref _kind env sigma c =
422427
results := mk_completion_item sigma ref env c :: results.contents;
423428
in
424-
Search.generic_search env display;
429+
generic_search env sigma display;
425430
results.contents
426431

427432
let get_completions options st =

language-server/dm/document.ml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,12 @@ let rec junk_sentence_end stream =
252252
| [] -> ()
253253
| _ -> Stream.junk () stream; junk_sentence_end stream
254254

255+
[%%if coq = "8.18"]
256+
exception E = Stream.Error
257+
[%%else]
258+
exception E = Grammar.Error
259+
[%%endif]
260+
255261
let rec parse_more synterp_state stream raw parsed errors =
256262
let handle_parse_error start msg =
257263
log @@ "handling parse error at " ^ string_of_int start;
@@ -290,7 +296,7 @@ let rec parse_more synterp_state stream raw parsed errors =
290296
let loc = Loc.get_loc @@ info in
291297
handle_parse_error start (loc, Pp.string_of_ppcmds @@ CErrors.iprint_no_report (e,info))
292298
end
293-
| exception (Stream.Error msg as exn) ->
299+
| exception (E msg as exn) ->
294300
let loc = Loc.get_loc @@ Exninfo.info exn in
295301
junk_sentence_end stream;
296302
handle_parse_error start (loc,msg)
@@ -388,4 +394,4 @@ module Internal = struct
388394
sentence.start
389395
sentence.stop
390396

391-
end
397+
end

language-server/dm/dune

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
(name dm)
33
(public_name vscoq-language-server.dm)
44
(modules :standard \ vscoqtop_proof_worker vscoqtop_tactic_worker)
5+
(preprocess (pps ppx_optcomp -- -cookie "ppx_optcomp.env=env ~coq:(Defined \"%{coq:version.major}.%{coq:version.minor}\")"))
56
(libraries base coq-core.sysinit coq-core.vernac coq-core.parsing lsp sel protocol language))
67

78
(executable

language-server/dm/executionManager.ml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,14 +182,22 @@ let interp_ast ~doc_id ~state_id ~st ~error_recovery ast =
182182
st, status, []
183183

184184
(* This adapts the Future API with our event model *)
185+
[%%if coq = "8.18"]
186+
let definition_using e s ~fixnames:_ ~using ~terms =
187+
Proof_using.definition_using e s ~using ~terms
188+
[%%else]
189+
let definition_using = Proof_using.definition_using
190+
[%%endif]
185191
let interp_qed_delayed ~proof_using ~state_id ~st =
192+
let lemmas = Option.get @@ st.Vernacstate.interp.lemmas in
186193
let f proof =
187194
let proof =
188195
let env = Global.env () in
189196
let sigma, _ = Declare.Proof.get_current_context proof in
190197
let initial_goals pf = Proofview.initial_goals Proof.((data pf).entry) in
191198
let terms = List.map (fun (_,_,x) -> x) (initial_goals (Declare.Proof.get proof)) in
192-
let using = Proof_using.definition_using env sigma ~using:proof_using ~terms in
199+
let names = Vernacstate.LemmaStack.get_all_proof_names lemmas in
200+
let using = definition_using env sigma ~fixnames:names ~using:proof_using ~terms in
193201
let vars = Environ.named_context env in
194202
Names.Id.Set.iter (fun id ->
195203
if not (List.exists Util.(Context.Named.Declaration.get_id %> Names.Id.equal id) vars) then
@@ -202,7 +210,6 @@ let interp_qed_delayed ~proof_using ~state_id ~st =
202210
let f, assign = Future.create_delegate ~blocking:false ~name:"XX" fix_exn in
203211
Declare.Proof.close_future_proof ~feedback_id:state_id proof f, assign
204212
in
205-
let lemmas = Option.get @@ st.Vernacstate.interp.lemmas in
206213
let proof, assign = Vernacstate.LemmaStack.with_top lemmas ~f in
207214
let control = [] (* FIXME *) in
208215
let opaque = Vernacexpr.Opaque in

language-server/dm/parTactic.ml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,11 @@ let assign_tac ~abstract res : unit Proofview.tactic =
6060
tclUNIT ()
6161
end)
6262

63+
[%%if coq = "8.18" || coq = "8.19"]
6364
let command_focus = Proof.new_focus_kind ()
65+
[%%else]
66+
let command_focus = Proof.new_focus_kind "vscoq_command_focus"
67+
[%%endif]
6468

6569
let worker_solve_one_goal { TacticJob.state; ast; goalno; goal } ~send_back =
6670
let focus_cond = Proof.no_cond command_focus in

0 commit comments

Comments
 (0)