Skip to content
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

introduce a fully featured version manager #230

Draft
wants to merge 18 commits into
base: master
Choose a base branch
from

Conversation

Techatrix
Copy link
Collaborator

@Techatrix Techatrix commented Sep 7, 2024

Installing Zig or ZLS with the extension doesn't properly handle switching between different Zig project.
You have to manually figure out which version to get and install it every time your switch to a project that requires a different Zig version. Same goes for ZLS. The vscode configuration for Zig also can't handle switching between devices (see #111)
Let's stop giving developer the ability to misconfigure their editor.

  1. No initial setup for Zig
  2. initial setup for ZLS is only 'yes' or 'no'
  3. Done!

Version Manager

This is how the extension selects which version of Zig to install:

  • set the zig.version config option (can be global or per-workspace)
  • manually set the version through the 'Select and Install' popup (per-workspace)
  • set minimum_zig_version in the build.zig of your workspace
  • add a .zigversion to your workspace which stores the desired Zig version

If none of the above apply, the latest tagged release of Zig is installed.
Installs are automatically uninstalled to not fill up disk storage too much.
Installs are verified with minisign
The version of ZLS is inferred from the Zig version.

Status Bar

Hovering over the "Editor Language Status" will show whether Zig and ZLS are installed + their versions. The Status Bar Item for Zig will turn red if is not installed. Clicking on it will open the 'Select and Install' popup.

Screenshot from 2024-09-07 21-23-59

Updated 'Select and Install' popup

  • added an option to manually specify the path to Zig
  • added an option to select Zig from PATH (if available)
  • display the exact version of nightly
  • display which versions are already installed on the host machine
  • if no network connection is available, only versions that are already installed are displayed

Screenshot from 2024-10-12 22-06-40

Remaining issues

  • The version lookup for nightly builds that are specified through the build.zig.zon is not working properly. see this TODO.
    • This is the main blocker for this PR. I still need to figure out how to solve it.
  • The zig.checkForUpdate config option and update command have been removed. It should be added back but with some adjustments.
  • add some documentation around these new features so that users know how to use them

I wanted to keep these changes as small as possible but I couldn't stop myself. 😞
Any feedback would be greatly appreciated.

@Techatrix
Copy link
Collaborator Author

@Vexu Any thoughts on these changes?

@Lygaen
Copy link

Lygaen commented Sep 24, 2024

I allowed myself to mention your PR here !
#232

I can remove it from the list if you desire

@Techatrix Techatrix force-pushed the techatrix/version-manager branch 2 times, most recently from 7c6cb52 to 1475806 Compare September 29, 2024 22:46
@Vexu
Copy link
Member

Vexu commented Sep 29, 2024

I'm guessing there is precedence for extensions downloading additional binaries unprompted when installed so I guess that is fine especially since it is from the official source. As long as overriding the path to the Zig binary still works these all seem like good changes. And sorry for taking so long to get to this.

These changes make ZLS an "invisible" component of the extension after the initial setup.

This also removes the `zig.zls.checkForUpdate` command. I am not sure if it even needs to be brought back. I've made sure that no error is reported if no internet connection is available. The last installed ZLS version should be reused.

closes #136 because `zig.zls.startRestart` will just enable ZLS instead of complaining
See the TODOs on what needs to be added to the VersionManager

fixes #111
This commit replaces the initial setup with the following mechanism:
1. Check if the "Install Zig" has been previously executed in the active workspace. If so, install that version.
2. If the workspace contains a `.zigversion`, install the given Zig version.
3. If the workspace contains a `build.zig.zon` with a `minimum_zig_version`, install the next available Zig version.
4. Otherwise fallback to the latest tagged release of Zig.

Some parts of this are not fully implemented.

fixes #111
- add the ability to remove the workspace zig-version
- add an option to manually specify the path to Zig
- add an option to select Zig from PATH (if available)
- display the exact version of nightly
- display which versions are already installed on the host machine
- make the popup usable without an internet connection
This unfortunately has a large impact on the bundle size: 600kb -> 1.3mb
It is expected to be removed in ZLS 0.14.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants