emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/zig-mode 284c743cfe 1/3: add zig-re-type


From: ELPA Syncer
Subject: [nongnu] elpa/zig-mode 284c743cfe 1/3: add zig-re-type
Date: Mon, 25 Mar 2024 19:01:34 -0400 (EDT)

branch: elpa/zig-mode
commit 284c743cfe5e79a691a4319179ddf5f167db4670
Author: mega-dean <mega_dean@fastmail.com>
Commit: mega-dean <mega_dean@fastmail.com>

    add zig-re-type
---
 test/zig-tests.el | 20 ++++++++++++++++++++
 zig-mode.el       |  3 ++-
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/test/zig-tests.el b/test/zig-tests.el
index ef7f8e0b97..dab4bb2dd2 100644
--- a/test/zig-tests.el
+++ b/test/zig-tests.el
@@ -118,6 +118,26 @@ const python =
      ("void" font-lock-type-face)
      )))
 
+(ert-deftest test-font-lock-parameters-with-periods ()
+  (zig-test-font-lock
+   "fn doSomething(arg: thing.with.periods) void {}"
+   '(("fn" font-lock-keyword-face)
+     ("doSomething" font-lock-function-name-face)
+     ("arg" font-lock-variable-name-face)
+     ("thing.with.periods" font-lock-type-face)
+     ("void" font-lock-type-face)
+     )))
+
+(ert-deftest test-font-lock-struct-type-with-periods ()
+  (zig-test-font-lock
+   "const S = struct { field: thing.with.periods }; "
+   '(("const" font-lock-keyword-face)
+     ("S" font-lock-variable-name-face)
+     ("struct" font-lock-keyword-face)
+     ("field" font-lock-variable-name-face)
+     ("thing.with.periods" font-lock-type-face)
+     )))
+
 ;; Test all permutations of '?', '*', '[]', '* const', and '[] const' for 3 of 
those in a row
 ;; For example, ??[]Bar or [][]const *Bar
 (ert-deftest test-font-lock-parameters-optionals-pointers-and-arrays ()
diff --git a/zig-mode.el b/zig-mode.el
index 2c400bd81c..6742917736 100644
--- a/zig-mode.el
+++ b/zig-mode.el
@@ -134,11 +134,12 @@ If given a SOURCE, execute the CMD on it."
   (concat "\\(?:" zig-re-optional "\\|" zig-re-pointer "\\|" zig-re-array 
"\\)*"))
 
 (defconst zig-re-identifier "[[:word:]_][[:word:]_[:digit:]]*")
+(defconst zig-re-type "[[:word:]_.][[:word:]_.[:digit:]]*")
 (defconst zig-re-type-annotation
   (concat (zig-re-grab zig-re-identifier)
           "[[:space:]]*:[[:space:]]*"
           zig-re-optionals-pointers-arrays
-          (zig-re-grab zig-re-identifier)))
+          (zig-re-grab zig-re-type)))
 
 (defun zig-re-definition (dtype)
   "Construct a regular expression for definitions of type DTYPE."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]