zigtools / zls

A Zig language server supporting Zig developers with features like autocomplete and goto definition
MIT License
2.61k stars 274 forks source link

Build on save should look for a "check" step #1918

Open Techatrix opened 3 weeks ago

Techatrix commented 3 weeks ago

Some projects (Example: Tigerbeetle, Ziggy) have added a top-level-step called "check" to their build.zig which compiles their project without emitting the final binary. This avoids the extra compilation time spend in LLVM.

ZLS should see if the project has such a step and prefer it over the "install" step when running build on save.

kristoff-it commented 3 days ago

Personally I think this would be a great addition and I would even take it one step further:

If a project has a "check" step, enable build on save automatically and use it. Otherwise the user would have to manually enable the build_on_save behavior to avoid unexpected freezes / resource hogging.

Maybe the config file could be changed to accept a "build_on_save_step" field which defaults to "check" when unset (and that does nothing if the defined step doesn't exist).

Lastly, IMO this could also be a good setting to offer per-project and not just as a global config.