Anyzls installs compatible zls version

anyzig is really nice. It reads build.zig.zon and installs required zig version. Handy for trying out latest std.Io stuff!

Though, stable zls sort of works with master zig, I was already inspired to write anyzls.

Shout out to https://github.com/jedisct1/zig-minisign. A reimplementation of minisign in Zig, that also can be used as a Zig module.

Zls website provides HTTP API, which given zig version returns compatible zls version. So, what was left is too glue everything together.

Here’s anyzls source code https://codeberg.org/knightpp/anyzls.

10 Likes

Note that anyzig already supports zls. You can build it with zig build zls in the anyzig repo. It’s a pitty perhaps that this is not mentioned in the readme.

5 Likes

Ooh, I didn’t know that.

@marler8997 maybe you should mention zls in the readme so people aren’t tempted to reinvent?

2 Likes

Why is zls not included in the released binary of anyzig?

anyzig is an indirection that handles version management of the zig executable and according to @neurocyte you can also build such an indirection for zls, so it doesn’t make sense to include any specific zls version in its binary, instead you can create an anyzls so to say (which then will automatically download a zls version, at least that seems like it works from taking a short look at the code, but would be good to add a description to the readme).

1 Like

When anyzig zls works it is perfect, but it does not always work. For example it can fetch zls for 0.14.0 but not for 0.15.2. (Bugfix: ZLS download using incorrect target by mirror-shades · Pull Request #68 · marler8997/anyzig · GitHub)

I’m not a user of zls so it’s been a bit of an afterthought. I actually don’t know whether people are using it or not? If people are I can try to find time to accommodate. I was thinking of just making anyzig itself support zls…the anyzig and anyzls binaries are almost identical. You’d just pass the"zls" parameter to the anyzig executable.

P.S. oh…there’s also an extra step that’s needed for zls…mapping a Zig version to a zls version. Will need to implement that.

2 Likes

Just out of curiosity: what LSP do you use, or simply none? I dont know any beside zls.

Editors must be able to launch zls; zig zls is not going to work, using a symbolic link from zls to zigany looks better. Not working zls is what preventing people from using zigany!

There was a pfg/fix-zls branch with a working patch for zls—I am using it right now, with an additional b.getInstallStep().dependOn(&install.step); in build.zig for zls executable—and it rocks :slight_smile:

There are some valid reasons that a programmer does not want tools for auto-completion, even syntax coloring. For example not using auto-completion leads to better—easy to remember—names in APIs.
I am still using zls mostly for its code navigation capabilities.

1 Like

From what I can see, virtually all editors support passing cli arguments to any LSP program that gets launched. Is this not correct?

Thats a very understandable reason. But as you mention, the navigation stuff is really helpful, as is function documentation. I also don’t use too much autocompletion, but the offered completions show me that everything is set up correctly (although, you can’t rely on this, since the LSP might have some internal quirks.)

I don’t use an LSP. I use emacs and the times I’ve tried using an LSP resulted in emacs crashing and becoming unresponsive. I blame emacs but it’s been hard to find an alternative editor that does everything I rely on.

It is not correct for the vscode zig plugin, it is always calling either a zls executable that is in the PATH, or a configured zls executable without the ability to provide arguments (the first call is using as argument: --version).

It is correct for helix, but a user must change the default configuration—it is inconvenient for an editor that just works.

It is fine to use a zls script that just calls zig zls; but I really don’t know how a windows user can handle it.

1 Like