[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/swift-mode c56f43c 395/496: Make faces customizable
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/swift-mode c56f43c 395/496: Make faces customizable |
Date: |
Sun, 29 Aug 2021 11:34:14 -0400 (EDT) |
branch: elpa/swift-mode
commit c56f43cecc3d1830c64439cf25ab79f3ae2a175a
Author: taku0 <mxxouy6x3m_github@tatapa.org>
Commit: taku0 <mxxouy6x3m_github@tatapa.org>
Make faces customizable
---
swift-mode-font-lock.el | 146 ++++++++++++++++++++++++++++++++++++++++--------
1 file changed, 124 insertions(+), 22 deletions(-)
diff --git a/swift-mode-font-lock.el b/swift-mode-font-lock.el
index 9389361..bd59722 100644
--- a/swift-mode-font-lock.el
+++ b/swift-mode-font-lock.el
@@ -32,6 +32,95 @@
;;; Code:
+;;; Customizations
+
+;;;###autoload
+(defgroup swift-mode:faces nil
+ "Font faces."
+ :group 'swift)
+
+(defface swift-mode:constant-keyword-face
+ '((t . (:inherit font-lock-constant-face)))
+ "Face for highlighting constant keywords
+
+That is, true, false, and nil."
+ :group 'swift-mode:faces)
+
+(defface swift-mode:preprocessor-keyword-face
+ '((t . (:inherit font-lock-preprocessor-face)))
+ "Face for highlighting preprocessor keywords.
+
+Exmpale: #if, #endif, and #selector."
+ :group 'swift-mode:faces)
+
+(defface swift-mode:keyword-face
+ '((t . (:inherit font-lock-keyword-face)))
+ "Face for highlighting keywords."
+ :group 'swift-mode:faces)
+
+(defface swift-mode:builtin-method-trailing-closure-face
+ '((t . (:inherit font-lock-builtin-face)))
+ "Face for highlighting builtin methods with trailing closure."
+ :group 'swift-mode:faces)
+
+(defface swift-mode:builtin-method-face
+ '((t . (:inherit font-lock-builtin-face)))
+ "Face for highlighting builtin methods."
+ :group 'swift-mode:faces)
+
+(defface swift-mode:builtin-function-trailing-closure-face
+ '((t . (:inherit font-lock-builtin-face)))
+ "Face for highlighting builtin functions with trailing closure."
+ :group 'swift-mode:faces)
+
+(defface swift-mode:builtin-function-face
+ '((t . (:inherit font-lock-builtin-face)))
+ "Face for highlighting builtin functions."
+ :group 'swift-mode:faces)
+
+(defface swift-mode:builtin-propertie-face
+ '((t . (:inherit font-lock-builtin-face)))
+ "Face for highlighting builtin properties."
+ :group 'swift-mode:faces)
+
+(defface swift-mode:builtin-enum-case-face
+ '((t . (:inherit font-lock-builtin-face)))
+ "Face for highlighting builtin enum cases."
+ :group 'swift-mode:faces)
+
+(defface swift-mode:build-config-keyword-face
+ '((t . (:inherit font-lock-builtin-face)))
+ "Face for highlighting build configuration keywords."
+ :group 'swift-mode:faces)
+
+(defface swift-mode:builtin-type-face
+ '((t . (:inherit font-lock-builtin-face)))
+ "Face for highlighting builtin types."
+ :group 'swift-mode:faces)
+
+(defface swift-mode:builtin-precedence-group-face
+ '((t . (:inherit font-lock-builtin-face)))
+ "Face for highlighting builtin precedence groups."
+ :group 'swift-mode:faces)
+
+(defface swift-mode:function-call-face
+ '((t . (:inherit font-lock-function-name-face)))
+ "Face for highlighting function calls."
+ :group 'swift-mode:faces)
+
+(defface swift-mode:function-name-face
+ '((t . (:inherit font-lock-function-name-face)))
+ "Face for highlighting function names."
+ :group 'swift-mode:faces)
+
+(defface swift-mode:property-access-face
+ '((t . (:inherit font-lock-variable-name-face)))
+ "Face for highlighting property accesses."
+ :group 'swift-mode:faces)
+
+
+;;; Supporting functions
+
(defun swift-mode:function-name-pos-p (pos limit)
"Return t if POS is just before the name of a function declaration.
@@ -118,6 +207,8 @@ Set `match-data', and return t if a property access found
before position LIMIT.
Return nil otherwise."
(swift-mode:font-lock-match-expr limit #'swift-mode:property-access-pos-p))
+;;; Keywords and standard identifiers
+
;; Keywords
;;
https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/LexicalStructure.html#//apple_ref/doc/uid/TP40014097-CH30-ID410
@@ -387,6 +478,8 @@ Excludes true, false, and keywords begin with a number
sign.")
"arm64" "iOSApplicationExtension" "OSXApplicationExtension")
"Keywords for build configuration statements.")
+;;; font-lock definition
+
(defconst swift-mode:font-lock-keywords
`(
;; Attributes
@@ -394,48 +487,55 @@ Excludes true, false, and keywords begin with a number
sign.")
(,(regexp-opt swift-mode:constant-keywords 'words)
.
- font-lock-constant-face)
+ 'swift-mode:constant-keyword-face)
(,(regexp-opt swift-mode:preprocessor-keywords 'symbols)
.
- font-lock-preprocessor-face)
+ 'swift-mode:preprocessor-keyword-face)
- ,(regexp-opt (append swift-mode:declaration-keywords
- swift-mode:statement-keywords
- swift-mode:expression-keywords
- swift-mode:context-keywords)
- 'words)
+ (,(regexp-opt (append swift-mode:declaration-keywords
+ swift-mode:statement-keywords
+ swift-mode:expression-keywords
+ swift-mode:context-keywords)
+ 'words)
+ .
+ 'swift-mode:keyword-face)
(,(concat "\\."
(regexp-opt swift-mode:member-functions-trailing-closure 'words)
"\\s-*[({]")
1
- font-lock-builtin-face)
+ 'swift-mode:builtin-method-trailing-closure-face)
(,(concat "\\."
(regexp-opt swift-mode:member-functions 'words)
"\\s-*(")
1
- font-lock-builtin-face)
+ 'swift-mode:builtin-method-face)
(,(concat (regexp-opt swift-mode:global-functions-trailing-closure 'words)
"\\s-*[({]")
1
- font-lock-builtin-face)
+ 'swift-mode:builtin-function-trailing-closure-face)
(,(concat (regexp-opt swift-mode:global-functions 'words)
"\\s-*(")
1
- font-lock-builtin-face)
+ 'swift-mode:builtin-function-face)
- (,(concat "\\." (regexp-opt (append swift-mode:properties
- swift-mode:enum-cases)
- 'words))
+ (,(concat "\\." (regexp-opt swift-mode:properties 'words))
1
- font-lock-builtin-face)
+ 'swift-mode:builtin-propertie-face)
- (,(regexp-opt (append swift-mode:build-config-keywords
- swift-mode:class-types
+ (,(concat "\\." (regexp-opt swift-mode:enum-cases 'words))
+ 1
+ 'swift-mode:builtin-enum-case-face)
+
+ (,(regexp-opt swift-mode:build-config-keywords 'words)
+ .
+ 'swift-mode:build-config-keyword-face)
+
+ (,(regexp-opt (append swift-mode:class-types
swift-mode:enum-types
swift-mode:foundation-protocols
swift-mode:foundation-structs
@@ -444,26 +544,28 @@ Excludes true, false, and keywords begin with a number
sign.")
swift-mode:typealiases)
'words)
.
- font-lock-builtin-face)
+ 'swift-mode:builtin-type-face)
(,(concat "\\<"
(regexp-opt swift-mode:precedence-groups 'non-nil)
"Precedence\\>")
.
- font-lock-builtin-face)
+ 'swift-mode:builtin-precedence-group-face)
;; Method/function calls
("\\<\\(\\(\\sw\\|\\s_\\)+\\)\\>\\??\\s-*("
1
- font-lock-function-name-face)
+ 'swift-mode:function-call-face)
;; Function declarations
- (swift-mode:font-lock-match-function-names . font-lock-function-name-face)
+ (swift-mode:font-lock-match-function-names
+ .
+ 'swift-mode:function-name-face)
;; Property accesses
(swift-mode:font-lock-match-property-accesss
.
- font-lock-variable-name-face))
+ 'swift-mode:property-access-face))
"Swift mode keywords for Font Lock.")
- [nongnu] elpa/swift-mode 030b1b8 356/496: Update documentations and wordings, (continued)
- [nongnu] elpa/swift-mode 030b1b8 356/496: Update documentations and wordings, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode d68af3c 365/496: Update copyright, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 359efc0 379/496: Fix indentation of function parameter clauses, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 25944c2 378/496: Add test for beginning/end-of-defun, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode ea029a0 370/496: Suppress implicit semicolons inside interpolated expressions, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode b5602c1 375/496: Add beginning/end-of-sentence to README.md, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 18c3dc4 376/496: Bump version to 4.0.0, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 27e959e 385/496: Handle unmatched parens correctly, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode abf3426 392/496: Add support for highlighting function calls / properties / enum cases, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 560242d 393/496: Add support for choosing scheme when building/running iOS projects, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode c56f43c 395/496: Make faces customizable,
ELPA Syncer <=
- [nongnu] elpa/swift-mode 6d4fab5 396/496: Move customizations for REPL to their own group, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 604610d 399/496: Fix LLDB breakpoint option, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 6fdb3cd 403/496: Fix `swift-mode:debug-swift-module`, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode d2f2f1d 410/496: Bump version to 6.0.0, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode f847923 419/496: Highlight more compiler directives, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 0b1e5e8 420/496: Support raw texts, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 348e153 422/496: Change buffer name of REPL, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 0eca818 431/496: Add test for Imenu, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode ddc7ae6 436/496: Fix `adaptive-fill-regexp` for multiline comments, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 2e9bdc6 430/496: Ignore import declarations in Imenu, ELPA Syncer, 2021/08/29