Page
Library
Module
Module type
Parameter
Class
Class type
Source
The coq-lsp
project aims to provide a lightweight, pure Language Server Protocol server implementation for the Coq proof assistant, as well as to serve as a framework for interface experimentation.
Warning: This project is at a early stage, and it has known bugs, see the issue tracker for more information. Use at your own risk. See install information for install instructions.
Moreover, we expect the code to evolve significantly, contributions are very welcome, but please first coordinate with the dev team before writing any code.
Our development channel can be found at Coq's Zulip, don't hesitate to stop by.
Edit your file, and coq-lsp
will try to re-check only what is necessary, continuously. No more dreaded Ctrl-C Ctrl-N
! Rechecking tries to be smart, and will ignore whitespace changes.
[insert gif]
In a future release, coq-lsp
will save its document cache to disk so you can restart your proof session where you left it at the last time.
Incremental support is undergoing refinement, if coq-lsp
rechecks when it should not, please file a bug!
coq-lsp
won't stop checking on errors, but support (and encourages) working with proof documents that are only partially working. Moreover, error recovery integrates with the incremental cache, and will recognize proof structure.
You can edit without fear inside a Proof. ... Qed.
, the rest of the document won't be rechecked, unless the proof is completed.
[insert gif]
Press Alt+Enter
(or Cmd+Enter
in Mac) to show goals at point in a side panel.
Open a markdown file with a .mv
extension, coq-lsp
will check the code parts! coq-lsp
places human friendly documents at the core of its design ideas.
[insert gif]
coq-lsp
supports document outline, allowing you to jump directly to definitions in the document.
[insert gif]
Hover over any Coq sentence, coq-lsp
will display detailed memory and timing statistics.
[insert gif]
coq-lsp
is configurable, and tries to adapt to your own workflow. What to do when a proof doesn't check, admit or ignore? You decide!
See the coq-lsp
extension configuration in VSCode for options available.
[insert gif]
The incremental document checking library of coq-lsp
has been designed to be reusable by other projects written in OCaml and with needs for document validation UI, as well as by other Coq projects such as jsCoq.
Moreover, we are strongly based on standards, aiming for the least possible extensions.
A key coq-lsp
goal is to serve as central platform for researchers in Human-Computer-Interaction, Machine Learning, and Software Engineering willing to interact with Coq.
Ẁith this goal, coq-lsp
extends and will eventually replace coq-serapi
, which has been used by many to that purpose.
In progress, pending on https://github.com/coq/coq/pull/16261
Configure which proofs to skip or delay, to make your document workflow more reactive.
Check only what is visible, à la Isabelle.
Don't worry about ever having to build your project again, coq-lsp
will detect your workspace and build setup, and will keep everything up to date automatically.
Supporting inlays and Lean-style infoview.
TODO
To build the server, you'll need and environment with the dependencies stated in coq-lsp.opam
. Opam users can do opam install --deps-only .
.
Once you have done that, do make
, and the server will be build under _build/install/default/bin/
There is a Nix flake available which will setup the necessery environment and can be used via nix develop
. You can then run make
as usual.
TODO
Assuming the server is built, install the extension as follows:
Symlink the editor/code
directory into ~/.vscode/extensions/
.
ln -s ~/path/to/coq-lsp/editor/code ~/.vscode
(link source should be absolute or else it won't work!)
Run npm install && npm run compile
in editor/code
.
(cd editor/code && npm i && npm run compile)
Now you can launch VS Code through dune
: dune exec -- code -n
, this will setup the right environment variables such as PATH
and OCAMLPATH
.
Alternatively, you can just install the server and run code
.
You can use this mode with eglot with $path_to_server --std
. Note that --std
is needed otherwise eglot will choke due to extra messages.
For now the main focus of the project to write clean and maintainable code, and to provide a smooth user experience.
A core goal at this stage is to provide feedback upstream so the Coq API can be tailored to provide a good interactive experience.
For the planned first release, we hope to provide a reasonable implementation of core LSP features, editor support in VS Code.
coq-lsp
consists of several components:
coq-serapi
: [vendored] improved utility functions to handle Coq ASTcoq
: Utility library / abstracted Coq API. This is the main entry point for communication with Coq.fleche
: incremental document processing backend. Exposes a generic API, but closely modelled to match LSP methodslsp
: small generic LSP utilities, at some point to be replaced by a generic libcontroller
: LSP controller, a thin layer translating LSP transport layer to flèche
surface API.The license for this project is LGPL 2.1 (or GPL 3+ as stated in the LGPL 2.1).
Work on this server has been made possible thanks to many discussions, inspirations, and sharing of ideas from colleagues. In particular we'd like to thank Rudi Grinberg, Andrey Mokhov, Clément Pit-Claudel, and Makarius Wenzel for their help and advice.