Skip to content

Commit

Permalink
Apply font-lock-custom-face to block labels
Browse files Browse the repository at this point in the history
c-mode applies `font-lock-constant-face` to labels (e.g. `foo:`) and
label references (e.g. `goto foo;`). Get zig-mode to do the equivalent
with block labels.
  • Loading branch information
ve-nt authored and joachimschmidt557 committed Nov 1, 2024
1 parent f55e425 commit 0931dcb
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions zig-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ If given a SOURCE, execute the CMD on it."
zig-re-optionals-pointers-arrays
(zig-re-grab zig-re-type)))

(defconst zig-re-block-label-open " \\([[:word:]]:\\) *{")
(defconst zig-re-block-label-break "break[[:space:]]*\\(:[[:word:]]+\\)")

(defun zig-re-definition (dtype)
"Construct a regular expression for definitions of type DTYPE."
(concat (zig-re-word dtype) "[[:space:]]+" (zig-re-grab zig-re-identifier)))
Expand Down Expand Up @@ -233,6 +236,10 @@ If given a SOURCE, execute the CMD on it."
symbol-end)
. font-lock-type-face)

;; Block labels
(,zig-re-block-label-open 1 font-lock-constant-face)
(,zig-re-block-label-break 1 font-lock-constant-face)

;; Type annotations (both variable and type)
(,zig-re-type-annotation 1 font-lock-variable-name-face)
(,zig-re-type-annotation 2 font-lock-type-face))
Expand Down

0 comments on commit 0931dcb

Please sign in to comment.