Evening gentlefolk,
I’ve spent a pleasant afternoon getting my head around how to use anyzig with the latest dev build, so that I can work through the Ziglings examples. This involved my uninstalling zig and zls that I had previously installed using brew - laziness I guess? - and now having managed to start plowing through with zig 0.16.0-dev.1859+212968c57 build , I’m beginning to miss not having zls available anymore.
Q: Is there some wave-a-dead-chicken incantation I need to get this to work, or am I S.O.L. and should just learn to suck it up. (For added comedy, I’m using Helix and not VS Code )
My suggestion would be to use the 0.15.1 tagged release of ziglings, instead of chasing master while learning Zig.
When using dev versions for Ziglings, Zig and Zls it can be difficult for all versions to match up, that is the benefit of tagged versions that those things are usually figured out correctly through those tagged releases.
It has been a while and my zls knowledge might be outdated but I remember zls needs to be rebuilt with the current installed version of zig to be compatible. I usually do these whenever I install a new version of zig.
Unpack zig in a directory, e.g. /opt/zig.
Get the source of zls or update it. E.g. in /opt/zls, git clone https://github.com/zigtools/zls.git git pull
If your zig version is not master or an older version, find the git tags of zls matching the zig version. git tag git checkout 0.15.0 (move HEAD to 0.15.0) git checkout master (move HEAD back to latest)
Do a build on zls in /opt/zls zig build
Copy the zls binary to a directory in $PATH. cp zig-out/bin/zls /opt/zig
Test running zls. Make sure its version is compatible with zig. zls --version zig version
while this is technically true, you can (and I do) get away with using a master build of zls when using 0.15.
You do have to be aware that zls might have false errors or completions, in particular the @Type on master has been replaced with specific bulitins for each kind of type.
That is specific to language changes, for example zls will work correctly with std or any other import, it just needs to execute the correct zig binary, which anyzig solves by using the minimum_zig_version from your build.zig.zon (when a specific version isnt passed as an arg, which is the case when zls calls it since it doesnt know its calling anyzig).
Thank you for this @ww520 and the kind welcome. Assuming I haven’t managed to conquer all 111 exercises by the end of the week, I will try this on the old Linux box at work, after the holidays. For now MacOS laziness has triumphed.