-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add project commands, command menu and walkthrough #334
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- standalone vs mathlib project creation - expose show output and install elan command - prevent showing "restart server" message while already restarting it - prevent client start crash softlocking the restart - client start progress bar - 'show output' button in command errors - use stable toolchain for new projects - write toolchain directly to file instead of doing so via re-curling - fetch cache after dependency update - better error messages for non-github projects - better output formatting
- lazily activate lean 4 features correctly - progress titles - active folder errors - no progress for version checks (too noisy)
The tests are currently broken due to the fact that the extension activation logic changed, which means that some components of the extension are exported later after activation than they used to, and so the tests can't find them. I will resolve this later; I want to get these changes out for a pre-release ASAP. |
Please still feel free to review this PR, as it will not be fully released until 2023-10-22. |
This was referenced Oct 19, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds several new commands, a command menu UI, a walkthrough guide that is displayed when the extension is installed and several related usability improvements. It also adds CI support for pre-releases.
New commands
Creating Projects
Two new commands to create projects have been added:
lean4.project.createStandaloneProject
andlean4.project.createMathlibProject
.Both commands display a file picker to select the location to create the project at, update Elan before creating the project, create the project using
lake init
and then runlake update
to generate thelake-manifest.json
file. Standalone projects useleanprover/lean4:stable
for their toolchain; mathlib projects useleanprover-community/mathlib4:lean-toolchain
.After creating a mathlib project,
lake exe cache get
is called.When the project is fully initialized, users are prompted whether they want to open the newly created project.
Opening Projects
Two new commands to open existing projects have been added:
lean4.project.open
andlean4.project.clone
.lean4.project.open
is intended to prevent users from accidentally opening the wrong folder. It displays a file picker and then checks if the selected folder is a valid Lean 4 project. The heuristic used here is the same as the one that has been used in the extension so far: If it contains alean-toolchain
file it is a valid Lean 4 project. If it containsLICENSE
andLICENSES
files, as well as asrc
folder, it is assumed to be Lean 4 itself and can also be opened with the command.If the selected folder is not a valid Lean 4 project, the command looks through parent folders to see if it can find one there. If it finds one, it suggests to open that one instead.
lean4.project.clone
shows an input that allows users to input a URL to a Git repository. Afterwards, a file picker is opened to select the folder to clone the project to. Then, it clones the project usinggit clone
, attempts to fetch the mathlib cache usinglake exe cache get
(failing silently if the command is not available) and asks whether the new project should be opened.Lake Commands
Four new commands for common Lake operations have been added:
lean4.project.build
,lean4.project.clean
,lean4.project.updateDependency
andlean4.project.fetchCache
. All of these commands can interfere with the language server, so the Lean client is automatically stopped before running the command and automatically restarted afterwards.lean4.project.build
fetches the mathlib cache if it is available and runslake build
afterwards.lean4.project.clean
displays a confirmation prompt, runslake clean
and then asks the user whether they want to immediately fetch the mathlib cache iflake exe cache
is available.lean4.project.fetchCache
simply fetches the mathlib cache iflake exe cache
is available.lean4.updateDependency
parses themanifest.json
of the project that is currently selected and fetches the current remote revision for each by callinggit ls-remote
with the input revision designated in the manifest. Dependencies that are still up-to-date are filtered. Then, a selection dialog is displayed to choose the dependency to update, what revision it is currently on and which one it will be updated to.After selecting a dependency, if the project is a GitHub project, the current remote
lean-toolchain
is automatically determined. If it differs from the currentlean-toolchain
of the project, a prompt is displayed, asking the user if they want to update theirlean-toolchain
to the remote version. If the project is not a GitHub project, users are asked whether they want to continue with updating the dependency without also updating the toolchain version.Finally, the new toolchain version is written,
lake update
is called to update the selected dependency and the mathlib cache is fetched iflake exe cache
is available.Elan
The command to install elan that used to be only accessible by opening a new Lean 4 file without having Lean installed has also been exposed as a command
lean4.setup.installElan
now.Command Menu
In the top right, a new menu with the ∀-quantifier from Lean's logo as an icon has been added. The menu provides access to all user-facing commands that the VS Code extension provides.
Since the menu can be used to open and create projects, as well as access documentation related to Lean, it is always displayed, even if no Lean 4 project is open. If one finds this annoying, it can be disabled with a new configuration setting. Certain commands are however only displayed when a Lean 4 file is open, e.g. building the project, as we need a file to determine the project that is currently active in multi-root workspaces.
Walkthrough
When the extension is first installed, a platform-specific walkthrough guide is opened that provides information on the following:
The walkthrough can always be re-opened through the "Documentation" submenu in the command menu.
Safeguards
If users accidentally open a folder that is not a Lean 4 project using VS Code's regular "Open Folder" command and then open a Lean file within it, a notification suggesting that a wrong folder has been opened is displayed. If there is a parent folder that is a valid Lean 4 project, the notification suggests to open that folder instead.
If users open a single Lean 4 file, a notification is displayed informing them that not all features are available in this mode and that they should open a project instead.
Both notifications can be disabled with a new configuration setting.
Other Usability Improvements