Skip to content

Commit 6acb3cb

Browse files
authored
Merge pull request #93 from kape1395/lsp
Language Server Protocol for TLAPM
2 parents 494f83b + 4d53b9e commit 6acb3cb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+5157
-96
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- macos-13
1717
- macos-14
1818
ocaml-compiler:
19-
- '4.13.1'
19+
- '4.14.1'
2020
- '5.1.0'
2121
env:
2222
EXAMPLES_DIR: "tlaplus-examples"
@@ -39,10 +39,15 @@ jobs:
3939
with:
4040
path: _build_cache
4141
key: ${{ runner.os }}_build_cache
42+
- name: Install optional dependencies
43+
if: startsWith(matrix.ocaml-compiler, '5.')
44+
run: |
45+
eval $(opam env)
46+
make opam-deps-opt
4247
- name: Build TLAPM
4348
run: |
4449
eval $(opam env)
45-
opam install ./ --deps-only --yes
50+
make opam-deps
4651
make
4752
make release
4853
- name: Run tests

.github/workflows/release.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,15 @@ jobs:
9797
with:
9898
path: _build_cache
9999
key: ${{ runner.os }}_build_cache
100+
- name: Install optional dependencies
101+
if: startsWith(matrix.ocaml-compiler, '5.')
102+
run: |
103+
eval $(opam env)
104+
make opam-deps-opt
100105
- name: Build installer of TLAPS
101106
run: |
102107
eval $(opam env)
103-
opam install ./ --deps-only --yes
108+
make opam-deps
104109
make
105110
make release
106111
echo "TLAPM_RELEASE_FILE=$(make release-print-file)" >> "$GITHUB_ENV"

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99

1010
/_build/
1111
/_build_cache/
12-
/.vscode/
12+
/.vscode/settings.json
1313
/tlaps-*.tar.gz
14+
/src/tlapm.bc
1415

1516
__pycache__/
1617
*.pyc

.ocamlformat

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
version=0.26.2
2+
profile=default

.vscode/cspell.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"words": [
3+
"tlaplus",
4+
"tlaps",
5+
"tlapm",
6+
"zenon",
7+
"opam",
8+
"ocaml",
9+
"caml",
10+
"sandboxing",
11+
"sprintf",
12+
"printexc"
13+
]
14+
}

Makefile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,11 @@ opam-update: # Update the package lists and install updates.
2424
opam-deps:
2525
opam install ./ --deps-only --yes --working-dir
2626

27+
opam-deps-opt:
28+
opam install --yes eio_main lsp
29+
2730
opam-deps-dev:
28-
opam install ocamlformat ocaml-lsp-server earlybird
31+
opam install --yes ocamlformat ocaml-lsp-server earlybird
2932

3033
build:
3134
dune build
@@ -44,6 +47,10 @@ test-fast:
4447
test-fast-basic:
4548
make -C test fast/basic
4649

50+
fmt:
51+
# Only the LSP part is not formatted automatically.
52+
cd lsp && dune fmt
53+
4754
install:
4855
dune install --prefix=$(PREFIX)
4956
make -C $(PREFIX)/lib/tlapm/ -f Makefile.post-install

dune-project

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
(license BSD-2-Clause)
1414

15+
(cram enable)
16+
1517
(package
1618
(name tlapm)
1719
(synopsis "TLA+ Proof Manager")
@@ -42,5 +44,11 @@
4244
dune-site
4345
dune-build-info
4446
sexplib
47+
cmdliner
48+
camlzip
49+
re2
4550
ppx_inline_test
46-
ppx_assert))
51+
ppx_assert)
52+
(depopts
53+
lsp ; https://github.com/ocaml/ocaml-lsp
54+
eio_main)) ; https://github.com/ocaml-multicore/eio, only available on OCaml version >= 5.

library/dune

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
(install
2-
(section (site (tlapm stdlib)))
3-
(files (glob_files "*.tla")))
2+
(section
3+
(site
4+
(tlapm stdlib)))
5+
(files
6+
(glob_files "*.tla")))

lsp/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# LSP interface to the TLAPS
2+
3+
The `tlapm_lsp` works as an adapter between the `tlapm` and code editors, e.g., VSCode.
4+
It is responsible for:
5+
- Parsing the document structure to locate features related to proofs, e.g.:
6+
- proof obligation by cursor position, possibly collecting all the subtree of obligations.
7+
- Running the `tlapm` on specific obligations and reporting the results.
8+
- Show progress of the tlapm, allow cancel it.
9+
- TODO: Proof re-numbering.
10+
- TODO: Proof decomposition.
11+
- TODO: Easier experimentation on missing facts.
12+
13+
The test folder contains a VSCode extension / LSP client. It is meant only for testing,
14+
the real integration should be done in the TLA+ VSCode extension.
15+
16+
See:
17+
- Dafny plugin. It shows all the obligations as testcases.
18+
<https://github.com/dafny-lang/ide-vscode>
19+
<https://github.com/dafny-lang/dafny/tree/master/Source/DafnyLanguageServer>
20+
- VSCode Decorators: https://github.com/microsoft/vscode-extension-samples/blob/main/decorator-sample/README.md
21+
https://vscode.rocks/decorations/
22+
Gutter -- the left side of the editor.
23+

lsp/bin/dune

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
(executable
2+
(name tlapm_lsp)
3+
(public_name tlapm_lsp)
4+
(optional) ; Only build, if eio is available, which is only the case for ocaml > 5.
5+
(enabled_if
6+
(>= %{ocaml_version}, "5.0.0"))
7+
(libraries tlapm_lsp_lib eio_main cmdliner))

0 commit comments

Comments
 (0)