ziglang / zig-mode

Zig mode for Emacs
GNU General Public License v3.0
166 stars 55 forks source link

Add flymake integration #93

Open zenMaya opened 1 year ago

zenMaya commented 1 year ago

Flymake is a pretty good backend to report compiler errors to. Better than compilation-mode. This commit allows, if user calls flymake-mode, to automatically call a zig command. It is zig build test but can be zig ast-check or similar. The errors are automatically reported to the buffer. This works project-wide with correct locations.

However, a small limitation is, that only one process can be spawned. This is because otherwise there would be much more code to check in a alist. (key would be either (project-current) or if nil (current-buffer))

I don't think it is a huge limitation, as the commands runs project-wide and most people won't run more than one project check at a time.

In the reference implementation the command is ran per buffer, which this implementation does not support. And that is why the limitation is here compared to the flymake manual (https://www.gnu.org/software/emacs/manual/html_node/flymake/An-annotated-example-backend.html).

jcs090218 commented 7 months ago

Why not create another package flymake-zig? Probably cleaner this way. 🤔

purcell commented 7 months ago

Every version of Emacs that zig-mode supports has a compatible modern flymake included, so here I wouldn't recommend splitting it into a separate package: it's fairly common and reasonable for a major mode to bundle some basic flymake support. I have some comments on the specifics of this PR, though, which I'll leave in a quick review.