tristanisham / zvm

zvm (Zig Version Manager) lets you easily install/upgrade between different versions of Zig.
https://www.zvm.app
MIT License
487 stars 32 forks source link

Add zls #15

Closed mutkach closed 1 year ago

mutkach commented 1 year ago

My request is more of a question about whether it makes sense to add zls as an optional part of installation (the same way as ghcup works, which allows to install hls, ghc, and its build systems).

My experience was that, when you install a master version of zig, you also get an outdated zls, which is a little inconvenient.

tristanisham commented 1 year ago

I'm not sure if this is within scope. How do you see the implementation working? @mutkach

dogue commented 1 year ago

ZLS pushes tags so you could possibly pull the tag that matches the selected Zig version. Not sure how it'd work for the master branch though.

SigSeg-V commented 1 year ago

I think it'd be good to have the option to. I created a fork with this feature by adding a flag --zls with the install command, for example zvm i master --zls Only master works so far because the tagged releases mentioned above ~require auth from Github's API afaik~. Edit: I have gotten releases to download in curl without an auth token (am noob, haven't used github api before) will implement soon.

SigSeg-V commented 1 year ago

Opened PR adding this feature.

TheFunctionalGuy commented 1 year ago

Another "hacky" solution is to clone the zls repository and then building the needed version with the correct prefix into the directory. So when using zvm use 0.11.0 it also changes the zls version.

This might be added to the README.md if it is not easily possible to implement zls installation as a feature.

Instructions

Command for 0.11.0 after cloning zls repository and being inside the folder:

git checkout 0.11.0
zig build --prefix-exe-dir ~/.zvm/0.11.0/ -Doptimize=ReleaseSafe

or for master:

git checkout master
zig build --prefix-exe-dir ~/.zvm/master/ -Doptimize=ReleaseSafe

Results

Using zvm use master results in:

$ zig version
0.12.0-dev.789+e6590fea1

$ zls --version
0.12.0-dev.133+ef3497c

and zvm use 0.11.0 as expected results in:

$ zig version
0.11.0

$ zls --version
0.11.0
tristanisham commented 1 year ago

zvm could handle the build step for you. If you enabled install_ZLS in the settings.json file, or passed it as a flag, if there was a version without a recompiled release ZVM could clone and build the zig projects for your system.

There's some support for ZVM in this capacity already built in. The sync command can already set Sky versions in a per-project basis. It wouldn't be hard to add a Zig runner so you could run different versions of Zig in the same project?

SigSeg-V commented 1 year ago

@tristanisham is compiling zls for each release more in line with zvm than downloading the releases and placing them in the release directory? Can pivot the open PR to go this direction if so.

tristanisham commented 1 year ago

@SigSeg-V I don't think so, but I wouldn't want ZLS to be installed in root with the rest of Zig. Maybe in a new directory? ~/.zvm/modules or ~/.zvm/vendor? I feel like the main directory is getting crowded.

Also, sorry about taking a while to respond. I'm just getting back from a trip. Will be on another one next week too.

SigSeg-V commented 1 year ago

No worries will work on that Sunday, been unusually busy at work. Have a good one :)

tristanisham commented 1 year ago

@SigSeg-V I've merged your request! Thanks for working so hard on this enhancement! Feel free to keep making PRs and tweaking with ZVM. I really appreciate your contributions! 😄