@@ -15,7 +15,7 @@ define(function(require, exports, module) {
15
15
"float64|complex64|complex128|byte|rune|uint|int|uintptr|bool|error"
16
16
) ;
17
17
var builtinFunctions = (
18
- "make |close|new| panic|recover"
18
+ "new |close|cap|copy| panic|panicln|print|println|len|make|delete|real| recover|imag|append "
19
19
) ;
20
20
var builtinConstants = ( "nil|true|false|iota" ) ;
21
21
@@ -24,7 +24,9 @@ define(function(require, exports, module) {
24
24
"constant.language" : builtinConstants ,
25
25
"support.function" : builtinFunctions ,
26
26
"support.type" : builtinTypes
27
- } , "identifier" ) ;
27
+ } , "" ) ;
28
+
29
+ var stringEscapeRe = "\\\\(?:[0-7]{3}|x\\h{2}|u{4}|U\\h{6}|[abfnrtv'\"\\\\])" . replace ( / \\ h / g, "[a-fA-F\\d]" ) ;
28
30
29
31
this . $rules = {
30
32
"start" : [
@@ -34,32 +36,43 @@ define(function(require, exports, module) {
34
36
} ,
35
37
DocCommentHighlightRules . getStartRule ( "doc-start" ) ,
36
38
{
37
- token : "comment" , // multi line comment
39
+ token : "comment.start " , // multi line comment
38
40
regex : "\\/\\*" ,
39
41
next : "comment"
40
42
} , {
41
43
token : "string" , // single line
42
- regex : '["] (?:(?:\\\\.)|(?: [^"\\\\]))*?["]'
44
+ regex : / " (?: [ ^ " \\ ] | \\ . ) * ? " /
43
45
} , {
44
- token : "string" , // single line
45
- regex : '[`](?:[^`]*)[`]'
46
- } , {
47
- token : "string" , // multi line string start
48
- merge : true ,
46
+ token : "string" , // raw
49
47
regex : '[`](?:[^`]*)$' ,
50
48
next : "bqstring"
51
49
} , {
52
50
token : "constant.numeric" , // rune
53
- regex : "['] (?:(?:\\\\.)|(?:[^'\\\\]))['] "
51
+ regex : "' (?:[^\\'\uD800-\uDBFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|" + stringEscapeRe . replace ( '"' , '' ) + ")' "
54
52
} , {
55
53
token : "constant.numeric" , // hex
56
- regex : "0[xX][0-9a-fA-F]+\\b"
54
+ regex : "0[xX][0-9a-fA-F]+\\b"
57
55
} , {
58
56
token : "constant.numeric" , // float
59
57
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
60
58
} , {
61
- token : keywordMapper ,
62
- regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
59
+ token : [ "keyword" , "text" , "entity.name.function" ] ,
60
+ regex : "(func)(\\s+)([a-zA-Z_$][a-zA-Z0-9_$]*)\\b"
61
+ } , {
62
+ token : function ( val ) {
63
+ if ( val [ val . length - 1 ] == "(" ) {
64
+ return [ {
65
+ type : keywordMapper ( val . slice ( 0 , - 1 ) ) || "support.function" ,
66
+ value : val . slice ( 0 , - 1 )
67
+ } , {
68
+ type : "paren.lparen" ,
69
+ value : val . slice ( - 1 )
70
+ } ] ;
71
+ }
72
+
73
+ return keywordMapper ( val ) || "identifier" ;
74
+ } ,
75
+ regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b\\(?"
63
76
} , {
64
77
token : "keyword.operator" ,
65
78
regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|==|=|!=|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^="
@@ -79,22 +92,20 @@ define(function(require, exports, module) {
79
92
] ,
80
93
"comment" : [
81
94
{
82
- token : "comment" , // closing comment
83
- regex : ".*? \\*\\/" ,
95
+ token : "comment.end" ,
96
+ regex : "\\*\\/" ,
84
97
next : "start"
85
98
} , {
86
- token : "comment" , // comment spanning whole line
87
- regex : ".+"
99
+ defaultToken : "comment" ,
88
100
}
89
101
] ,
90
102
"bqstring" : [
91
103
{
92
104
token : "string" ,
93
- regex : '(?:[^`]*) `' ,
105
+ regex : '`' ,
94
106
next : "start"
95
107
} , {
96
- token : "string" ,
97
- regex : '.+'
108
+ defaultToken : "string"
98
109
}
99
110
]
100
111
} ;
0 commit comments