From 5536991f40078cfadd77c6fcda9011bb76f9599b Mon Sep 17 00:00:00 2001 From: Philipp Leo Dylong Date: Fri, 29 Apr 2016 21:21:21 +0200 Subject: [PATCH 1/6] - added Standard Libraries - fixed and improved some Standard Types - made ! more visible --- swift.nanorc | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/swift.nanorc b/swift.nanorc index 5b64222..999b09a 100644 --- a/swift.nanorc +++ b/swift.nanorc @@ -1,5 +1,5 @@ ############################################################################## -# Swift syntax highlighting for Nano. +# Swift syntax highlighting for Nano. v.1.04 ############################################################################## syntax "Swift" "\.swift$" @@ -9,27 +9,37 @@ color white ".+" # Operators color yellow "[.:;,+*|=!?\%]" "<" ">" "/" "-" "&" +color brightyellow "[!]" # Statements -color magenta "(class|import|let|var|struct|enum|func|if|else|switch|case|default|for|in|internal|external|unowned|private|public|throws)\ " -color magenta "(prefix|postfix|operator|extension|lazy|get|set|self|willSet|didSet|override|super|convenience|weak|strong|mutating|return|guard)\ " +color magenta "\b(class|import|let|var|struct|enum|func|if|else|switch|case|default|for|in|internal|external|unowned|private|public|throws)\b" +color magenta "\b(prefix|postfix|operator|extension|lazy|get|set|self|willSet|didSet|override|super|convenience|weak|strong|mutating|return|guard)\b" # Keywords -color cyan "(print)" -color magenta "(init)" +color cyan "\b(print)\b" +color magenta "\b(init)\b" # Numbers -color blue "([0-9]+)" +color blue "\b([0-9]+)\b" # Standard Types -color brightmagenta "\ ((U)?Int(8|16|32|64))" -color brightmagenta "(true|false|nil)" -color brightmagenta "\ (Double|String|Float|Boolean|Dictionary|Array|Int)" -color magenta "\ (AnyObject)" +color brightmagenta "\b((U)?Int(8|16|32|64))\b" +color brightmagenta "\b(true|false|nil)\b" +color brightmagenta "\b(Double|String|Float|Bool|Dictionary|Array|Int|UInt|Character|Range|Set|UnicodeScalar|Bit|RawByte|Slice|UnsafePointer|UnsafeMutablePointer)\b" +color magenta "\b(AnyObject)\b" + +# Standard Type Aliases and Protocols +color magenta "\b(AnyObject|AnyClass|GeneratorType|AnyGenerator|Element|Optional|Mirror|UnicodeScalarType|IntMax|UIntMax|Void|Any|Comparable|Equatable|Hashable|SequenceType)\b" + +# Standard Libraries +color cyan "\b(Foundation|Glibc|Darwin|XCTest|)\b" # Text color red ""[^"]*"" +# Variable in Text +color white start="\\\(" end="\)" + # Comments color green "//.*" color brightgreen "///.*" From 2358b0f7c2320150588c5aed6135b057e4fec577 Mon Sep 17 00:00:00 2001 From: Philipp Date: Fri, 29 Apr 2016 21:32:22 +0200 Subject: [PATCH 2/6] ups --- swift.nanorc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/swift.nanorc b/swift.nanorc index 999b09a..d71207b 100644 --- a/swift.nanorc +++ b/swift.nanorc @@ -32,7 +32,7 @@ color magenta "\b(AnyObject)\b" color magenta "\b(AnyObject|AnyClass|GeneratorType|AnyGenerator|Element|Optional|Mirror|UnicodeScalarType|IntMax|UIntMax|Void|Any|Comparable|Equatable|Hashable|SequenceType)\b" # Standard Libraries -color cyan "\b(Foundation|Glibc|Darwin|XCTest|)\b" +color cyan "\b(Foundation|Glibc|Darwin|XCTest)\b" # Text color red ""[^"]*"" From beb092d8985648dca8d3a104cbde4eed57b068b1 Mon Sep 17 00:00:00 2001 From: Philipp Date: Tue, 3 May 2016 13:06:39 +0200 Subject: [PATCH 3/6] fixed some regex not working on osx. Regex Word boundary "\b" not working on OSX, relaced with Start "\<" and End of Word "\>". --- swift.nanorc | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/swift.nanorc b/swift.nanorc index d71207b..d0960f9 100644 --- a/swift.nanorc +++ b/swift.nanorc @@ -12,27 +12,27 @@ color yellow "[.:;,+*|=!?\%]" "<" ">" "/" "-" "&" color brightyellow "[!]" # Statements -color magenta "\b(class|import|let|var|struct|enum|func|if|else|switch|case|default|for|in|internal|external|unowned|private|public|throws)\b" -color magenta "\b(prefix|postfix|operator|extension|lazy|get|set|self|willSet|didSet|override|super|convenience|weak|strong|mutating|return|guard)\b" +color magenta "\<(class|import|let|var|struct|enum|func|if|else|switch|case|default|for|in|internal|external|unowned|private|public|throws)\>" +color magenta "\<(prefix|postfix|operator|extension|lazy|get|set|self|willSet|didSet|override|super|convenience|weak|strong|mutating|return|guard)\>" # Keywords -color cyan "\b(print)\b" -color magenta "\b(init)\b" +color cyan "\<(print)\>" +color magenta "\<(init)\>" # Numbers -color blue "\b([0-9]+)\b" +color blue "\<([0-9]+)\>" # Standard Types -color brightmagenta "\b((U)?Int(8|16|32|64))\b" -color brightmagenta "\b(true|false|nil)\b" -color brightmagenta "\b(Double|String|Float|Bool|Dictionary|Array|Int|UInt|Character|Range|Set|UnicodeScalar|Bit|RawByte|Slice|UnsafePointer|UnsafeMutablePointer)\b" -color magenta "\b(AnyObject)\b" +color brightmagenta "\<((U)?Int(8|16|32|64))\>" +color brightmagenta "\<(true|false|nil)\>" +color brightmagenta "\<(Double|String|Float|Bool|Dictionary|Array|Int|UInt|Character|Range|Set|UnicodeScalar|Bit|RawByte|Slice|UnsafePointer|UnsafeMutablePointer)\>" +color magenta "\<(AnyObject)\>" # Standard Type Aliases and Protocols -color magenta "\b(AnyObject|AnyClass|GeneratorType|AnyGenerator|Element|Optional|Mirror|UnicodeScalarType|IntMax|UIntMax|Void|Any|Comparable|Equatable|Hashable|SequenceType)\b" +color magenta "\<(AnyObject|AnyClass|GeneratorType|AnyGenerator|Element|Optional|Mirror|UnicodeScalarType|IntMax|UIntMax|Void|Any|Comparable|Equatable|Hashable|SequenceType)\>" # Standard Libraries -color cyan "\b(Foundation|Glibc|Darwin|XCTest)\b" +color cyan "\<(Foundation|Glibc|Darwin|XCTest)\>" # Text color red ""[^"]*"" From 8afb5e604dd1eb826531ac14703ae95fc51fb31b Mon Sep 17 00:00:00 2001 From: Philipp Date: Tue, 3 May 2016 21:27:40 +0200 Subject: [PATCH 4/6] added static to statements --- swift.nanorc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/swift.nanorc b/swift.nanorc index d0960f9..7204e04 100644 --- a/swift.nanorc +++ b/swift.nanorc @@ -12,7 +12,7 @@ color yellow "[.:;,+*|=!?\%]" "<" ">" "/" "-" "&" color brightyellow "[!]" # Statements -color magenta "\<(class|import|let|var|struct|enum|func|if|else|switch|case|default|for|in|internal|external|unowned|private|public|throws)\>" +color magenta "\<(class|import|let|var|struct|enum|func|if|else|switch|case|default|for|in|internal|external|unowned|static|private|public|throws)\>" color magenta "\<(prefix|postfix|operator|extension|lazy|get|set|self|willSet|didSet|override|super|convenience|weak|strong|mutating|return|guard)\>" # Keywords From f8f7242417f439278b66c695c9868d493650f85c Mon Sep 17 00:00:00 2001 From: Philipp Leo Dylong Date: Thu, 5 May 2016 11:21:18 +0200 Subject: [PATCH 5/6] added Attributes case -added Attributes case highlight words beginning with a @ sing -made some lines more compact for readability --- swift.nanorc | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/swift.nanorc b/swift.nanorc index 7204e04..ab56c6f 100644 --- a/swift.nanorc +++ b/swift.nanorc @@ -1,5 +1,5 @@ ############################################################################## -# Swift syntax highlighting for Nano. v.1.04 +# Swift syntax highlighting for Nano. v.1.1 ############################################################################## syntax "Swift" "\.swift$" @@ -12,24 +12,30 @@ color yellow "[.:;,+*|=!?\%]" "<" ">" "/" "-" "&" color brightyellow "[!]" # Statements -color magenta "\<(class|import|let|var|struct|enum|func|if|else|switch|case|default|for|in|internal|external|unowned|static|private|public|throws)\>" -color magenta "\<(prefix|postfix|operator|extension|lazy|get|set|self|willSet|didSet|override|super|convenience|weak|strong|mutating|return|guard)\>" +color magenta "\<(class|import|let|var|struct|enum|func|if|else|switch|case|default|for|in|static|private|public|throws)\>" +color magenta "\<(lazy|get|set|self|willSet|didSet|override|super|convenience|weak|strong|mutating|return|guard)\>" +color magenta "\<(protocol|typealias|prefix|postfix|operator|extension|internal|external|unowned)\>" # Keywords color cyan "\<(print)\>" color magenta "\<(init)\>" +# Attribute +color red "(@+[a-zA-Z]+)" + # Numbers color blue "\<([0-9]+)\>" # Standard Types color brightmagenta "\<((U)?Int(8|16|32|64))\>" color brightmagenta "\<(true|false|nil)\>" -color brightmagenta "\<(Double|String|Float|Bool|Dictionary|Array|Int|UInt|Character|Range|Set|UnicodeScalar|Bit|RawByte|Slice|UnsafePointer|UnsafeMutablePointer)\>" +color brightmagenta "\<(UInt|Int|Double|String|Float|Bool|Dictionary|Array|Character|Range|Set|Bit|RawByte|Slice)\>" +color brightmagenta "\<(UnicodeScalar|UnsafePointer|UnsafeMutablePointer)\>" color magenta "\<(AnyObject)\>" # Standard Type Aliases and Protocols -color magenta "\<(AnyObject|AnyClass|GeneratorType|AnyGenerator|Element|Optional|Mirror|UnicodeScalarType|IntMax|UIntMax|Void|Any|Comparable|Equatable|Hashable|SequenceType)\>" +color magenta "\<(AnyObject|AnyClass|GeneratorType|AnyGenerator|Element|Optional|Mirror)\>" +color magenta "\<(UnicodeScalarType|IntMax|UIntMax|Void|Any|Comparable|Equatable|Hashable|SequenceType)\>" # Standard Libraries color cyan "\<(Foundation|Glibc|Darwin|XCTest)\>" From 39f19f3d6eb6532873fe991f5708203aad1c02c0 Mon Sep 17 00:00:00 2001 From: Philipp Leo Dylong Date: Thu, 5 May 2016 12:07:14 +0200 Subject: [PATCH 6/6] added Unicode and Integer Literals --- swift.nanorc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/swift.nanorc b/swift.nanorc index ab56c6f..d1af78e 100644 --- a/swift.nanorc +++ b/swift.nanorc @@ -23,8 +23,16 @@ color magenta "\<(init)\>" # Attribute color red "(@+[a-zA-Z]+)" -# Numbers +# Numbers / Decimal Literal color blue "\<([0-9]+)\>" +# Unicode Literal "U+" +color blue "\<(U\++[0-9A-Z]+)\>" +# Binary Literal "0b" +color blue "\<(0b+[0-1]+)\>" +# Octal Literal "0o" +color blue "\<(0o+[0-7]+)\>" +# Hexadecimal Literal "0x" +color blue "\<(0x+[0-9A-Fa-f]+)\>" # Standard Types color brightmagenta "\<((U)?Int(8|16|32|64))\>"