Make sure ZLS is installed.
In build.zig, add a check step after exe:
const exe_check = b.addExecutable(.{
.name = "YOUR_PROJECT",
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
});
// Add all deps here just like your exe
const check = b.step("check", "Check if it compiles");
check.dependOn(&exe_check.step);
Your ZLS settings must now be:
{
"enable_build_on_save": true,
"build_on_save_step": "check"
}
In VSCode, I suggest you also install Error Lens extension to see errors in-line.
Now you should have live error checks!
For full description, read the full article by Loris Cro.