ziglang / zig-mode

Zig mode for Emacs
GNU General Public License v3.0
157 stars 54 forks source link

Fix font-lock of parameters with optional, pointer or array types #59

Closed eric-p-hutchins closed 3 years ago

eric-p-hutchins commented 3 years ago

I've been playing with zig for a bit and this has been driving me crazy:

zig-mode-fix

Uses the special Elisp "shy group" construct that I found out (also called "non-capturing" or "unnumbered group")

This changes the regex from:

(identifier) (possible whitespace) (colon) (possible whitespace) (identifier)

to:

(identifier) (possible whitespace) (colon) (possible whitespace) (any number of (* or * const) OR ([] or [] const with anything inside the []) OR ?) (possible whitespace) (identifier)

eric-p-hutchins commented 3 years ago

This does have this unfortunate side effect of making it look like only the next identifier is the type rather than the entire expression. Maybe it's ok for now though? It's certainly a big improvement regardless.

Also I'm not sure if that behavior is really related to this fix, but might be a separate issue.

@joachimschmidt557 What do you think?