branch: elpa/swift-mode commit 18e1e4a0eb8d2134c366223759a0632148bd7e33 Author: ap4y <l...@pisem.net> Commit: ap4y <l...@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