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

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

[nongnu] elpa/swift-mode 18e1e4a 107/496: Highlight attributes as keywor


From: ELPA Syncer
Subject: [nongnu] elpa/swift-mode 18e1e4a 107/496: Highlight attributes as keyword
Date: Sun, 29 Aug 2021 11:33:17 -0400 (EDT)

branch: elpa/swift-mode
commit 18e1e4a0eb8d2134c366223759a0632148bd7e33
Author: ap4y <lod@pisem.net>
Commit: ap4y <lod@pisem.net>

    Highlight attributes as keyword
---
 swift-mode.el           | 13 +++++++++++++
 test/font-lock-tests.el |  2 ++
 2 files changed, 15 insertions(+)

diff --git a/swift-mode.el b/swift-mode.el
index 1e289cb..72ac60e 100644
--- a/swift-mode.el
+++ b/swift-mode.el
@@ -249,6 +249,11 @@
     "nonmutating" "operator" "override" "postfix" "precedence" "prefix" "right"
     "set" "unowned" "unowned(safe)" "unowned(unsafe)" "weak" "willSet" 
"convenience"))
 
+(defvar swift-mode--attribute-keywords
+  '("assignment" "class_protocol" "exported" "final" "lazy" "noreturn"
+    "NSCopying" "NSManaged" "objc" "optional" "required" "auto_closure"
+    "IBAction" "IBDesignable" "IBInspectable" "IBOutlet"))
+
 (defvar swift-mode--keywords
   (append swift-mode--type-decl-keywords
           swift-mode--val-decl-keywords
@@ -275,6 +280,14 @@
        t)
      1 font-lock-keyword-face)
 
+    ;; Attributes
+    ;;
+    ;; Highlight attributes with keyword face
+    (,(rx-to-string
+       `(and "@" bow (or ,@swift-mode--attribute-keywords) eow)
+       t)
+     0 font-lock-keyword-face)
+
     ;; Types
     ;;
     ;; Any token beginning with an uppercase character is highlighted as a
diff --git a/test/font-lock-tests.el b/test/font-lock-tests.el
index acd14b0..e0e7650 100644
--- a/test/font-lock-tests.el
+++ b/test/font-lock-tests.el
@@ -188,6 +188,8 @@ test will fail."
 
 (check-face string-interpolation/has-variable-face/1 
font-lock-variable-name-face "\"foo {{\\\(bar)}}\"")
 
+(check-face attributes/has-keyword-face/1 font-lock-keyword-face 
"{{@IBAction}} func")
+
 (provide 'font-lock-tests)
 
 ;;; font-lock-tests.el ends here



reply via email to

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