84
|
1 ##############################################################################
|
|
2 # Swift syntax highlighting for Nano. v.1.1
|
|
3 ##############################################################################
|
|
4
|
|
5 syntax "Swift" "\.swift$"
|
|
6
|
|
7 # Default
|
|
8 color white ".+"
|
|
9
|
|
10 # Operators
|
|
11 color yellow "[.:;,+*|=!?\%]" "<" ">" "/" "-" "&"
|
|
12 color brightyellow "[!]"
|
|
13
|
|
14 # Statements
|
|
15 color magenta "\<(class|import|let|var|struct|enum|func|if|else|switch|case|default|for|in|static|private|public|throws)\>"
|
|
16 color magenta "\<(lazy|get|set|self|willSet|didSet|override|super|convenience|weak|strong|mutating|return|guard)\>"
|
|
17 color magenta "\<(protocol|typealias|prefix|postfix|operator|extension|internal|external|unowned)\>"
|
|
18
|
|
19 # Keywords
|
|
20 color cyan "\<(print)\>"
|
|
21 color magenta "\<(init)\>"
|
|
22
|
|
23 # Attribute
|
|
24 color red "(@+[a-zA-Z]+)"
|
|
25
|
|
26 # Numbers / Decimal Literal
|
|
27 color blue "\<([0-9]+)\>"
|
|
28 # Unicode Literal "U+"
|
|
29 color blue "\<(U\++[0-9A-Z]+)\>"
|
|
30 # Binary Literal "0b"
|
|
31 color blue "\<(0b+[0-1]+)\>"
|
|
32 # Octal Literal "0o"
|
|
33 color blue "\<(0o+[0-7]+)\>"
|
|
34 # Hexadecimal Literal "0x"
|
|
35 color blue "\<(0x+[0-9A-Fa-f]+)\>"
|
|
36
|
|
37 # Standard Types
|
|
38 color brightmagenta "\<((U)?Int(8|16|32|64))\>"
|
|
39 color brightmagenta "\<(true|false|nil)\>"
|
|
40 color brightmagenta "\<(UInt|Int|Double|String|Float|Bool|Dictionary|Array|Character|Range|Set|Bit|RawByte|Slice)\>"
|
|
41 color brightmagenta "\<(UnicodeScalar|UnsafePointer|UnsafeMutablePointer)\>"
|
|
42 color magenta "\<(AnyObject)\>"
|
|
43
|
|
44 # Standard Type Aliases and Protocols
|
|
45 color magenta "\<(AnyObject|AnyClass|GeneratorType|AnyGenerator|Element|Optional|Mirror)\>"
|
|
46 color magenta "\<(UnicodeScalarType|IntMax|UIntMax|Void|Any|Comparable|Equatable|Hashable|SequenceType)\>"
|
|
47
|
|
48 # Standard Libraries
|
|
49 color cyan "\<(Foundation|Glibc|Darwin|XCTest)\>"
|
|
50
|
|
51 # Text
|
|
52 color red ""[^"]*""
|
|
53
|
|
54 # Variable in Text
|
|
55 color white start="\\\(" end="\)"
|
|
56
|
|
57 # Comments
|
|
58 color green "//.*"
|
|
59 color brightgreen "///.*"
|
|
60 color green start="/\*\*" end="\*/"
|
|
61 color green "[/**]"
|
|
62
|
|
63 # Trailing whitespace
|
|
64 color ,green "[[:space:]]+$"
|