Home

Awesome

Lean4ij

Build Version Downloads

image (The screenshot is taken from mathematics_in_lean) and some video:

https://github.com/user-attachments/assets/25757345-0249-4999-adc7-7dadf94c8b0e

<!-- Plugin description -->

A Lean4 plugin for the Intellij Platform.

Installation

This plugin uses LSP4IJ for connecting to the Lean4 language server. Please install that first.

The plugin should be compatible from version 2024.1 and can not support the earlier versions for depending some experimental api)

Usage

For currently there is no functionality of creating a project or setting up a project. Before open any lean project with it please first testing if the project has set up the toolchain correctly. Run any command like elan which lake or lake exe cache get, or lake build etc.

The LSP server is start as any lean file is open in the Editor and the editor gets focus. If it not behaves correctly, try firing a restart action.

Unicode is supported via live templates, for example typing \b1<SPACE> would result in 𝟙. For the limitation of live templates, the <SPACE> keypress is always required.

Infoview is supported using lean4-infoview, and currently it can be started from a browser or the internal JCEF infoview toolwindow. If it not behaves correctly, try firing a restart action too. There is also an infoview implemented in swing that's native in Jetbrains platform, it contains some basic functionally. Currently, some terminologies are messed up here: all the terminologies like "jcef", "external", "browser", "vscode" refer to the first one and terminologies like "swing", "internal", "native" refer to the second one.

Messages and logs about the lean lsp server can be found in the language server tool window after setting the level to message or trace, check more information about this in redhat-developer/lsp4ij.

Actions

Currently, the following actions are defined, mostly without default shortcut. Add one for them in Keymap (like Control Shift Enter for toggle infoview)

action idaction textdefault shortcut
ToggleLeanInfoViewInternalLean4 Actions: Toggle Infoview (internal)
ToggleLeanInfoViewJcefLean4 Actions: Toggle Infoview (jcef)
IncreaseZoomLevelForLeanInfoViewJcefLean4 Actions: Increase zoom level for lean infoview (jcef)
DecreaseZoomLevelForLeanInfoViewJcefLean4 Actions: Decrease zoom level for lean infoview (jcef)
ResetZoomLevelForLeanInfoViewJcefLean4 Actions: Reset zoom level for lean infoview (jcef)
OpenExternalInfoviewInBrowserLean4 Actions: Open infoview in browser
RestartLeanLspLean4 Actions: Restart Lean Lsp Server
RestartCurrentLeanFileLean4 Actions: Restart Current Lean File
RestartJcefInfoviewLean4 Actions: Restart Jcef Infoview
AddInlayGoalHintLean4 Actions: Add Inlay Goal HintControl I
DelInlayGoalHintLean4 Actions: Delete Inlay Goal HintControl Shift I

Settings

Since version 0.0.17 there are some settings available:

The inlay hints related settings are under Settings/Preferences > Inlay Hints > textmate:

Some color settings are under Settings/Preferences > Editor > Color Scheme > Lean Infoview. It contains color settings for both the external and internal infoview.

<!-- Plugin description end -->

Development

Please check DEVELOP.md.

Known Issues

The plugin is still on an early stage, check ISSUES.md for known and logged issues, and TODO.md

Troubleshooting

For showing debug/trace log, add lean4ij:all in MENU > Help > Diagnostic Tools > Debug Log Settings and restart, see How-to-enable-debug-logging-in-IntelliJ-IDEA for more docs.

Acknowledgments

The following projects give great help for developing the plugin:

and many source codes with references to

Plugin based on the IntelliJ Platform Plugin Template.