Is there some option to make so ZLS doesn’t stop after one error. For example with this code
const std = @import("std");
pub fn main() void {
const a = smth1;
const b = smth2;
}
It will highlight the first line in the main, but not the second (at least on the latest master branch build). If you delete or comment the first line out, it will now highlight the second one.
Though not a huge deal most of the time. It can be annoying when you fix one error and then it highlights another one that was completely unrelated and you have to fix them one by one.
Can you fix more than one error at a time? I can’t. I don’t think it’s outlandish to want them all to display, but it hadn’t occurred to me as something to want, either.
I don’t think your description is quite what happens, but it’s not far off, and it’s related to how ZLS gets errors in the first place: from the Zig compiler. Or, parts of it at least.
If you check this file you’ll see that it’s returning as many errors as it has, and it’s getting them from a std.zig.ErrorBundle. As such this behavior is not especially easy to change or configure.
There are those who know ZLS internals much better than I, and maybe they’ll chime in.
I think that depends on the kinds of errors (and essentially if they are dependent on one another or not) and how you define “at a time”.
I’m not using ZLS but a terminal emulator with zig build test --watch (or zig build unittests --watch) on a side monitor or virtual desktop if I don’t have one and quite frankly, only ever getting one kind of error is imo annoying.
I look at the side monitor to know what the current errors are, look at my main monitor again, fix them, save, and look at the side monitor again to look at which errors showed up now.
This cycle would get sped up a lot if I could see more errors at once when I look at the side monitor.
Before somebody suggests it: I don’t like multiple windows sharing a monitor at the same time. Kinda messes with my concentration.
But an even bigger annoyance for me is actually CI. I don’t have certain machines to test locally, so I need to push the code to a CI for checking. And since some code paths are target dependent, if there’s a compile time error, that slows things down a lot if I need to push multiple times to even see all (compile) errors.
I use a similar setup with tests running continiously in a seperate terminal window. I actually use two such windows, one with the test running on my server (different architecture) while using syncthing to share the code.
That gives a slightly delay in the second test, but at least no manual intervention (or committing and pushing) is needed, to notice something is wrong.
For one project I had a bunch of different targets running via qemu on a side monitor with --watch and that made it quite a nice experience to test and debug.
Unused variables are an ast-check error so they happen pretty early in the compiler pipeline. Once you move past those into semantic analysis errors, you will find that ZLS (through the Zig compiler output) will show many errors at once.
It would be nice if unused variable didn’t prevent analysis of the rest of source code. In this example:
fn (a: u8, b: SomeStruct) u8 {
return b * b;
}
It should be possible for the compiler to report the misuse of b and the unuse of a.
Proving you can always do that seems more complex though, maybe the zig team does not have the bandwith for this kind of improvement right now.
I’m guessing you’re on 0.16-dev? From what I’ve seen there are quite a few improvements compared to 0.15. Find all references is another thing that’s mostly broken for me on 0.15 but it looks to be improved in 0.16.