Skip to content
This repository was archived by the owner on Nov 26, 2025. It is now read-only.

Commit 284c743

Browse files
committed
add zig-re-type
1 parent b6f5375 commit 284c743

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

test/zig-tests.el

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,26 @@ const python =
118118
("void" font-lock-type-face)
119119
)))
120120

121+
(ert-deftest test-font-lock-parameters-with-periods ()
122+
(zig-test-font-lock
123+
"fn doSomething(arg: thing.with.periods) void {}"
124+
'(("fn" font-lock-keyword-face)
125+
("doSomething" font-lock-function-name-face)
126+
("arg" font-lock-variable-name-face)
127+
("thing.with.periods" font-lock-type-face)
128+
("void" font-lock-type-face)
129+
)))
130+
131+
(ert-deftest test-font-lock-struct-type-with-periods ()
132+
(zig-test-font-lock
133+
"const S = struct { field: thing.with.periods }; "
134+
'(("const" font-lock-keyword-face)
135+
("S" font-lock-variable-name-face)
136+
("struct" font-lock-keyword-face)
137+
("field" font-lock-variable-name-face)
138+
("thing.with.periods" font-lock-type-face)
139+
)))
140+
121141
;; Test all permutations of '?', '*', '[]', '* const', and '[] const' for 3 of those in a row
122142
;; For example, ??[]Bar or [][]const *Bar
123143
(ert-deftest test-font-lock-parameters-optionals-pointers-and-arrays ()

zig-mode.el

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,12 @@ If given a SOURCE, execute the CMD on it."
134134
(concat "\\(?:" zig-re-optional "\\|" zig-re-pointer "\\|" zig-re-array "\\)*"))
135135

136136
(defconst zig-re-identifier "[[:word:]_][[:word:]_[:digit:]]*")
137+
(defconst zig-re-type "[[:word:]_.][[:word:]_.[:digit:]]*")
137138
(defconst zig-re-type-annotation
138139
(concat (zig-re-grab zig-re-identifier)
139140
"[[:space:]]*:[[:space:]]*"
140141
zig-re-optionals-pointers-arrays
141-
(zig-re-grab zig-re-identifier)))
142+
(zig-re-grab zig-re-type)))
142143

143144
(defun zig-re-definition (dtype)
144145
"Construct a regular expression for definitions of type DTYPE."

0 commit comments

Comments
 (0)