Home

Awesome

Lean 3 for VS Code (deprecated)

This extension adds support for an older version of Lean, Lean 3. It is succeeded by vscode-lean4 (also called Lean 4 in the extensions menu) for Lean 4. If you want to use Lean 4, you cannot use this extension and must instead use vscode-lean4.

Features

We currently support a variety of features. For basic VS Code editor features, see the VS Code User Interface docs.

Lean 3 language server support

<!--- TODO(Bryan): fix this or remove it * Type of the term under the cursor can be displayed in the status bar --->

Lean 3 editing features

Info view panel

The info view panel is essential to working interactively with Lean 3. It shows:

<img src="media/infoview-overview.png">

(1) - (9) below refer to the labels in the screenshot above.

The icons labeled (2) - (6) and (9) - (10) appear at the top of each tactic state widget.

  1. The info view will activate automatically when a Lean 3 file is opened, but you can also click <img src="media/display-goal-light.png"> at the top right of the editor window or hit the keybind for the lean.displayGoal (<kbd>ctrl</kbd>+<kbd>shift</kbd>+<kbd>enter</kbd> by default) to reopen it.

  2. Copy-to-comment: click <img src="media/copy-to-comment.png" width="16px"> to copy the contents of the widget to a comment in the editor:

    <img src="media/copy-to-comment-example.png">
  3. Pin / unpin: click <img src="media/pin.png" width="16px"> to split off a "pinned" tactic state widget, which tracks the tactic state at a fixed position, even if you move your cursor away:

    <img src="media/pin-example.png">

    Some new icons appear:

    • Reveal file location: clicking <img src="media/reveal-file-location.png" width="16px"> will move the cursor in the editor to the pinned location in the file.
    • Unpin: clicking <img src="media/unpin.png" width="16px"> will remove the pinned widget from the info view.
  4. Pause / continue: clicking <img src="media/pause.png" width="16px"> will prevent the tactic state widget from updating when the file is edited. Click <img src="media/continue.png" width="16px"> to resume updates.

  5. Update: clicking <img src="media/update.png" width="16px"> will refresh the tactic state of the pinned widget.

  6. Suggest: clicking <img src="media/suggest.png" width="16px"> will activate api-based suggestions. The API url and key for these suggestions can be configured through options lean.suggestionURL and lean.suggestionAPIKey.

  7. (Lean 3.15.0c and newer) Types in the context can be examined in the tactic state widget by clicking on the subterms:

    <img src="media/inspect-term-example-1.png" width="250px">

    The subterms that appear in the popup are buttons; click on them to inspect their types:

    <img src="media/inspect-term-example-2.png" width="250px">
  8. The "All Messages" widget can be expanded by clicking on it (or hitting the keybind for lean.displayList, <kbd>ctrl</kbd>+<kbd>alt</kbd>+<kbd>shift</kbd>+<kbd>enter</kbd> by default)

    <img src="media/expand-all-messages.png">
  9. Widget / plain text selection: For Lean 3 versions older than Lean 3.15.0c, the tactic state is displayed as a non-interactive string. For newer versions of Lean 3, the widget mode (with features described in (6)) is used by default. This dropdown menu allows selecting between the two.

  10. Tactic state filter: the hypotheses in the tactic state can be filtered, with options on whether the tactic state is being displayed as a widget or in plain text (see (8)).

Documentation view

The book "Theorem Proving in Lean" can be read by hitting <kbd>ctrl</kbd>+<kbd>shift</kbd>+<kbd>p</kbd> and searching for "Lean: Open Documentation View".

Any Lean 3 project with an html/ folder can be displayed in this panel. For example, try out the book Mathematics in Lean.

Requirements

This extension requires an installation of Lean 3. As of version 0.12.1, the extension can install Lean 3 for you using elan.

On Windows, if you installed Lean 3 using MSYS2, you need to add both C:\msys64\mingw64\bin (or wherever you installed MSYS2) and C:\projects\lean\bin (or wherever you installed Lean 3) to the system PATH environment variable. To do this, press <kbd>Win</kbd>+<kbd>Pause</kbd> > go to Advanced System Settings > go to Environment variables. Under system variables (not user variables) find the Path variable, and add these two folders.

Extension Settings

This extension contributes the following settings (for a complete list, open the VS Code Settings and scroll to "Lean configuration"):

Server settings

Input / editing settings

<!-- TODO(Bryan): fix or remove * `lean.typeInStatusBar`: controls whether the type of the term under the cursor is displayed as a status bar item (`true` by default). -->

Info view settings

API settings

Extension commands

This extension also contributes the following commands, which can be bound to keys if desired.

The format below is: "lean.commandName (command name): description", where lean.commandName represents the name used in settings.json and "command name" is the name found in the command palette (accessed by hitting <kbd>ctrl</kbd>+<kbd>shift</kbd>+<kbd>p</kbd>).

Server commands

Editing commands

Info view commands

Doc view

Other potentially helpful settings

Development

Release Notes

0.16.21

0.16.0

0.15.13

0.15.0

0.14.0

0.13.3

0.13.1

0.13.0

0.12.1

0.11.2

0.11

0.10.1

0.10.0

0.9.0

0.8.0

0.7.2

0.7.1

0.7.0

0.6.6

0.6.5

Add support for detecting Lean server versions.

0.6.4

Add support for time and memory limits.

0.6.2

Consider angle brackets and parenthesis when completing Unicode symbols.

0.6.0

Bug fixes, stability, and a handful of feature improvements

0.4.0

Implement many features implemented by the EMACS mode. We now support:

0.3.0

Add basic integration with the Lean server.

0.1.0

Initial release of the package.


Contact

Please report issues on Github. Questions can also be asked on the Lean prover community Zulip chat.