Skip to content

Commit 441be73

Browse files
author
Dave Abrahams
authored
Merge pull request #4088 from GyazSquare/feature-improve-swift-mode
[swift-mode.el] improve swift mode
2 parents 29c93d3 + 8b1a234 commit 441be73

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

utils/swift-mode.el

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,28 @@
4444
`(,(regexp-opt '("class" "init" "deinit" "extension" "fileprivate" "func"
4545
"import" "let" "protocol" "static" "struct" "subscript"
4646
"typealias" "enum" "var" "lazy" "where"
47-
"private" "public" "internal" "override" "throws"
48-
"open" "associatedtype")
47+
"private" "public" "internal" "override" "throws" "rethrows"
48+
"open" "associatedtype" "inout" "indirect" "final")
49+
'words) . font-lock-keyword-face)
50+
;; Variable decl keywords
51+
`("\\b\\(?:[^a-zA-Z_0-9]*\\)\\(get\\|set\\)\\(?:[^a-zA-Z_0-9]*\\)\\b" 1 font-lock-keyword-face)
52+
`(,(regexp-opt '("willSet" "didSet") 'words) . font-lock-keyword-face)
53+
;; Operators
54+
`("\\b\\(?:\\(?:pre\\|post\\|in\\)fix\\s-+\\)operator\\b" . font-lock-keyword-face)
55+
;; Keywords that begin with a number sign
56+
`("#\\(if\\|endif\\|elseif\\|else\\|available\\)\\b" . font-lock-string-face)
57+
`("#\\(file\\|line\\|column\\|function\\|selector\\)\\b" . font-lock-keyword-face)
58+
;; Infix operator attributes
59+
`(,(regexp-opt '("precedence" "associativity" "left" "right" "none")
4960
'words) . font-lock-keyword-face)
5061
;; Statements
51-
`(,(regexp-opt '("if" "guard" "in" "else" "for" "do" "repeat" "while" "return"
52-
"break" "continue" "switch" "case" "default"
53-
"throw" "try" "catch")
62+
`(,(regexp-opt '("if" "guard" "in" "else" "for" "do" "repeat" "while"
63+
"return" "break" "continue" "fallthrough" "switch" "case"
64+
"default" "throw" "defer" "try" "catch")
65+
'words) . font-lock-keyword-face)
66+
;; Decl modifier keywords
67+
`(,(regexp-opt '("convenience" "dynamic" "mutating" "nonmutating" "optional"
68+
"required" "weak" "unowned" "safe" "unsafe")
5469
'words) . font-lock-keyword-face)
5570
;; Expressions
5671
`(,(regexp-opt '("new") 'words) . font-lock-keyword-face)

0 commit comments

Comments
 (0)