A Lean(4) Theorem Prover extension for Zed.
- Tree-sitter: tree-sitter-lean
- Language Server: Lean Language Server
The Lean Language Server is integrated with the Lean toolchain. It is recommended to manage Lean toolchain versions via elan. For example, you can install the stable Lean version by running:
elan default stable
lean --version- For optimal highlighting, set
"semantic_tokens"to"combined", which will enable LSP semantic tokens highlight in Zed.
- Abbreviation (unicode character) insertion is supported by snippets.
- Firstly, the extension will check
pathandargumentsinlsp.lean4-lsp.binarysettings. Then it will searchlakein$PATH, try$ELAN_HOMEand default directory. - If Lean 4 is not detected, this extension can automatically install elan with default toolchain. To enable this feature, you must set
"elan_auto_install"totrue. You can also specify the default toolchain by setting"elan_default_toolchain"to"stable","nightly"or"v4.28.0". - During installation, the extension will automatically add
~/.elanto your $PATH. The Lean toolchain can be completely removed by runningelan self uninstall.
{
"semantic_tokens": "combined",
"lsp": {
"lean4-lsp": {
"binary": {
"path": "/path/to/your/.elan/bin/lake",
"arguments": ["serve", "--"]
},
"settings": {
"elan_auto_install": true,
"elan_default_toolchain": "stable"
}
}
}
}- Implement infoview like VSCode and Neovim
- Tree-sitter-lean is experimental and needs improvement
- Update and uninstall elan
To develop this extension, see the Developing Extensions section of the Zed docs.