|
6 | 6 |
|
7 | 7 | "patterns": [ |
8 | 8 | { |
9 | | - "comment": "Single-line comment", |
10 | | - "name": "comment.line.double-dash.lua", |
11 | | - "match": "--(?!\\[=*\\[).*", |
12 | 9 | "captures": { |
13 | | - "1": { "name": "punctuation.definition.comment.lua"} |
14 | | - } |
| 10 | + "1": { |
| 11 | + "name": "keyword.control.lua" |
| 12 | + }, |
| 13 | + "2": { |
| 14 | + "name": "entity.name.function.scope.lua" |
| 15 | + }, |
| 16 | + "3": { |
| 17 | + "name": "entity.name.function.lua" |
| 18 | + }, |
| 19 | + "4": { |
| 20 | + "name": "punctuation.definition.parameters.begin.lua" |
| 21 | + }, |
| 22 | + "5": { |
| 23 | + "name": "variable.parameter.function.lua" |
| 24 | + }, |
| 25 | + "6": { |
| 26 | + "name": "punctuation.definition.parameters.end.lua" |
| 27 | + } |
| 28 | + }, |
| 29 | + "match": "\\b(function)(?:\\s+([a-zA-Z_.:]+[.:])?([a-zA-Z_]\\w*)\\s*)?(\\()([^)]*)(\\))", |
| 30 | + "name": "meta.function.lua" |
15 | 31 | }, |
16 | 32 | { |
17 | | - "comment": "Multi-line comment", |
18 | | - "name": "comment.line.block.lua", |
19 | | - "begin": "--\\[(=*)\\[", |
20 | | - "beginCaptures": { |
21 | | - "0": { "name": "punctuation.definition.comment.begin.lua" } |
22 | | - }, |
23 | | - "end": "\\]\\1\\]", |
24 | | - "endCaptures": { |
25 | | - "0": { "name": "punctuation.definition.comment.begin.lua" } |
26 | | - } |
| 33 | + "match": "(?<![\\d.])\\s0x[a-fA-F\\d]+|\\b\\d+(\\.\\d+)?([eE]-?\\d+)?|\\.\\d+([eE]-?\\d+)?", |
| 34 | + "name": "constant.numeric.lua" |
27 | 35 | }, |
28 | | - |
29 | 36 | { |
30 | | - "comment": "String (single quoted)", |
31 | 37 | "begin": "'", |
32 | 38 | "beginCaptures": { |
33 | | - "0": { "name": "punctuation.definition.string.begin.lua" } |
| 39 | + "0": { |
| 40 | + "name": "punctuation.definition.string.begin.lua" |
| 41 | + } |
34 | 42 | }, |
35 | 43 | "end": "'", |
36 | 44 | "endCaptures": { |
37 | | - "0": { "name": "punctuation.definition.string.end.lua" } |
| 45 | + "0": { |
| 46 | + "name": "punctuation.definition.string.end.lua" |
| 47 | + } |
38 | 48 | }, |
39 | 49 | "name": "string.quoted.single.lua", |
40 | 50 | "patterns": [ |
41 | 51 | { |
42 | | - "comment": "Special characters", |
43 | | - "match": "\\\\([abfnrtv']|\\d{1,3}|[xX]\\h\\h|u\\{\\h{,7}\\})", |
| 52 | + "include": "punctuation.definition.string.begin.lua" |
| 53 | + }, |
| 54 | + { |
| 55 | + "include": "punctuation.definition.string.end.lua" |
| 56 | + }, |
| 57 | + { |
| 58 | + "match": "\\\\.", |
44 | 59 | "name": "constant.character.escape.lua" |
45 | 60 | } |
46 | 61 | ] |
47 | 62 | }, |
48 | 63 | { |
49 | | - "comment": "String (double quoted)", |
50 | 64 | "begin": "\"", |
51 | 65 | "beginCaptures": { |
52 | | - "0": { "name": "punctuation.definition.string.begin.lua" } |
| 66 | + "0": { |
| 67 | + "name": "punctuation.definition.string.begin.lua" |
| 68 | + } |
53 | 69 | }, |
54 | 70 | "end": "\"", |
55 | 71 | "endCaptures": { |
56 | | - "0": { "name": "punctuation.definition.string.end.lua" } |
| 72 | + "0": { |
| 73 | + "name": "punctuation.definition.string.end.lua" |
| 74 | + } |
57 | 75 | }, |
58 | 76 | "name": "string.quoted.double.lua", |
59 | 77 | "patterns": [ |
60 | 78 | { |
61 | | - "comment": "Special characters", |
62 | | - "match": "\\\\([abfnrtv\"]|\\d{1,3}|[xX]\\h\\h|u\\{\\h{,7}\\})", |
| 79 | + "include": "punctuation.definition.string.begin.lua" |
| 80 | + }, |
| 81 | + { |
| 82 | + "include": "punctuation.definition.string.end.lua" |
| 83 | + }, |
| 84 | + { |
| 85 | + "match": "\\\\.", |
63 | 86 | "name": "constant.character.escape.lua" |
64 | 87 | } |
65 | 88 | ] |
66 | 89 | }, |
67 | 90 | { |
68 | | - "comment": "String (multiline)", |
69 | | - "begin": "(?<!--)\\[(=*)\\[", |
| 91 | + "begin": "(?<=\\.cdef)\\s*(\\[(=*)\\[)", |
70 | 92 | "beginCaptures": { |
71 | | - "0": { "name": "punctuation.definition.string.begin.lua" } |
| 93 | + "0": { |
| 94 | + "name": "string.quoted.other.multiline.lua" |
| 95 | + }, |
| 96 | + "1": { |
| 97 | + "name": "punctuation.definition.string.begin.lua" |
| 98 | + } |
72 | 99 | }, |
73 | | - "end": "\\]\\1\\]", |
| 100 | + "contentName": "meta.embedded.lua", |
| 101 | + "end": "(\\]\\2\\])", |
74 | 102 | "endCaptures": { |
75 | | - "0": { "name": "punctuation.definition.string.end.lua" } |
| 103 | + "0": { |
| 104 | + "name": "string.quoted.other.multiline.lua" |
| 105 | + }, |
| 106 | + "1": { |
| 107 | + "name": "punctuation.definition.string.end.lua" |
| 108 | + } |
76 | 109 | }, |
77 | | - "name": "string.quoted.single.lua", |
78 | 110 | "patterns": [ |
79 | 111 | { |
80 | | - "comment": "Special characters", |
81 | | - "match": "\\\\([abfnrtv\\[\\]]|\\d{1,3}|[xX]\\h\\h|u\\{\\h{,7}\\})", |
82 | | - "name": "constant.character.escape.lua" |
| 112 | + "include": "source.c" |
83 | 113 | } |
84 | 114 | ] |
85 | 115 | }, |
86 | | - |
87 | 116 | { |
88 | | - "comment": "Functions", |
89 | | - "match": "\\b(function)(?:\\s+([a-zA-Z_.:]+[.:])?([a-zA-Z_]\\w*)\\s*)?(\\()([^)]*)(\\))", |
90 | | - "name": "meta.function.lua", |
91 | | - "captures": { |
92 | | - "1": { |
93 | | - "name": "keyword.control.lua" |
94 | | - }, |
95 | | - "2": { |
96 | | - "name": "entity.name.function.scope.lua" |
97 | | - }, |
98 | | - "3": { |
99 | | - "name": "entity.name.function.lua" |
100 | | - }, |
101 | | - "4": { |
102 | | - "name": "punctuation.definition.parameters.begin.lua" |
103 | | - }, |
104 | | - "5": { |
105 | | - "name": "variable.parameter.function.lua" |
106 | | - }, |
107 | | - "6": { |
108 | | - "name": "punctuation.definition.parameters.end.lua" |
| 117 | + "begin": "(?<!--)\\[(=*)\\[", |
| 118 | + "beginCaptures": { |
| 119 | + "0": { |
| 120 | + "name": "punctuation.definition.string.begin.lua" |
109 | 121 | } |
110 | | - } |
| 122 | + }, |
| 123 | + "end": "\\]\\1\\]", |
| 124 | + "endCaptures": { |
| 125 | + "0": { |
| 126 | + "name": "punctuation.definition.string.end.lua" |
| 127 | + } |
| 128 | + }, |
| 129 | + "name": "string.quoted.other.multiline.lua" |
111 | 130 | }, |
112 | | - |
113 | 131 | { |
114 | | - "comment": "Metamethods", |
115 | | - "match": "(?<!^\\.|[^.]\\.|:)\\b(__(?:add|call|concat|div|eq|index|len|le|lt|mod|mode|mul|newindex|pow|sub|unm)|print)\\b", |
116 | | - "name": "support.function.metamethod.lua" |
| 132 | + "begin": "--\\[(=*)\\[", |
| 133 | + "captures": { |
| 134 | + "0": { |
| 135 | + "name": "punctuation.definition.comment.lua" |
| 136 | + } |
| 137 | + }, |
| 138 | + "end": "\\]\\1\\]", |
| 139 | + "name": "comment.block.lua" |
117 | 140 | }, |
118 | | - |
119 | 141 | { |
120 | | - "comment": "Variables (language)", |
121 | | - "match": "(?<!^\\.|[^.]\\.|:)\\b(self|this)\\b|((?<![.])\\.{3}(?!\\.)|_G|_VERSION)", |
122 | | - "name": "variable.language.lua" |
| 142 | + "begin": "(^[ \\t]+)?(?=--(?!\\[(=*)\\[))", |
| 143 | + "beginCaptures": { |
| 144 | + "1": { |
| 145 | + "name": "punctuation.whitespace.comment.leading.lua" |
| 146 | + } |
| 147 | + }, |
| 148 | + "end": "(?!\\G)", |
| 149 | + "patterns": [ |
| 150 | + { |
| 151 | + "begin": "--", |
| 152 | + "beginCaptures": { |
| 153 | + "0": { |
| 154 | + "name": "punctuation.definition.comment.lua" |
| 155 | + } |
| 156 | + }, |
| 157 | + "end": "\\n", |
| 158 | + "name": "comment.line.double-dash.lua" |
| 159 | + } |
| 160 | + ] |
123 | 161 | }, |
124 | | - |
125 | 162 | { |
126 | | - "comment": "Constants", |
127 | | - "match": "(?<!^\\.|[^.]\\.|:)\\b(true|nil|false)\\b", |
128 | | - "name": "constant.language.lua" |
| 163 | + "match": "\\b(and|or|not|break|do|else|for|if|elseif|return|then|repeat|while|until|end|function|local|in|goto)\\b", |
| 164 | + "name": "keyword.control.lua" |
129 | 165 | }, |
130 | | - |
131 | 166 | { |
132 | | - "comment": "Numeric", |
133 | | - "match": "(?<![\\d.])\\b0[xX][a-fA-F\\d\\.]+([pP][\\-\\+]?\\d+)?|\\b\\d+(\\.\\d+)?([eE]-?\\d+)?|\\.\\d+([eE]-?\\d+)?", |
134 | | - "name": "constant.numeric.lua" |
| 167 | + "match": "(?<![^.]\\.|:)\\b([A-Z_]+|false|nil|true|math\\.(pi|huge))\\b|(?<![.])\\.{3}(?!\\.)", |
| 168 | + "name": "constant.language.lua" |
135 | 169 | }, |
136 | | - |
137 | 170 | { |
138 | | - "comment": "Keywords", |
139 | | - "match": "\\b(break|do|else|for|if|elseif|return|then|repeat|while|until|end|function|local|in)\\b", |
140 | | - "name": "keyword.control.lua" |
| 171 | + "match": "(?<![^.]\\.|:)\\b(self)\\b", |
| 172 | + "name": "variable.language.self.lua" |
141 | 173 | }, |
142 | | - |
143 | 174 | { |
144 | | - "comment": "Lua basic functions", |
145 | | - "match": "(?<!^\\.|[^.]\\.|:)\\b(assert|collectgarbage|dofile|error|getfenv|getmetatable|ipairs|load|loadfile|loadstring|next|pairs |pcall|rawequal|rawset|select|setfenv|setmetatable|tonumber|tostring|type|unpack|xpcall)\\b", |
| 175 | + "match": "(?<![^.]\\.|:)\\b(assert|collectgarbage|dofile|error|getfenv|getmetatable|ipairs|loadfile|loadstring|module|next|pairs|pcall|print|rawequal|rawget|rawset|require|select|setfenv|setmetatable|tonumber|tostring|type|unpack|xpcall)\\b(?=\\s*(?:[({\"']|\\[\\[))", |
146 | 176 | "name": "support.function.lua" |
147 | 177 | }, |
148 | 178 | { |
149 | | - "comment": "Lua collections library", |
150 | | - "match": "(?<!^\\.|[^.]\\.|:)\\b(coroutine\\.(create|resume|running|status|wrap|yield)|debug\\.(debug|getfenv|gethook|getinfo|getlocal|getmetatable|getregistry|getupvalue|setfenv|sethook|setlocal|setmetatable|setupvalue|traceback)|io\\.(close|flush|input|lines|open|output|popen|read|stderr|stdin|stdout|tmpfile|type|write)|file\\:(close|flush|lines|read|seek|stvbuf|write)|match\\.(abs|acos|asin|atan|atan2|ceil|cos|cosh|deg|exp|floor|fmod|frexp|huge|idexp|log|log10|max|min|modf|pi|pow|rad|random|randomseed|sin|sinh|sqrt|tan|tanh)|os\\.(clock|date|difftime|execute|exit|getenv|remove|rename|setlocale|time|tmpname)|package\\.(cpath|loaded|loaders|loadlib|path|preload|seeall)|string\\.(byte|char|dump|find|format|gmatch|gsub|len|lower|match|rep|reverse|sub|upper)|table\\.(concat|insert|maxn|remove|sort))\\b", |
| 179 | + "match": "(?<![^.]\\.|:)\\b(coroutine\\.(create|resume|running|status|wrap|yield)|string\\.(byte|char|dump|find|format|gmatch|gsub|len|lower|match|rep|reverse|sub|upper)|table\\.(concat|insert|maxn|remove|sort)|math\\.(abs|acos|asin|atan2?|ceil|cosh?|deg|exp|floor|fmod|frexp|ldexp|log|log10|max|min|modf|pow|rad|random|randomseed|sinh?|sqrt|tanh?)|io\\.(close|flush|input|lines|open|output|popen|read|tmpfile|type|write)|os\\.(clock|date|difftime|execute|exit|getenv|remove|rename|setlocale|time|tmpname)|package\\.(cpath|loaded|loadlib|path|preload|seeall)|debug\\.(debug|[gs]etfenv|[gs]ethook|getinfo|[gs]etlocal|[gs]etmetatable|getregistry|[gs]etupvalue|traceback))\\b(?=\\s*(?:[({\"']|\\[\\[))", |
151 | 180 | "name": "support.function.library.lua" |
152 | 181 | }, |
153 | 182 | { |
154 | | - "comment": "Lua ponctuation functions library", |
155 | | - "match": "(?<=\\w|\\)|\\])(:)(?:(byte|char|dump|find|format|gfind|gmatch|gsub|len|lower|match|rep|reverse|sub|trim|upper))\\b", |
156 | | - "captures": { |
157 | | - "0": { "name": "support.function.lua" } |
158 | | - } |
| 183 | + "match": "\\b([A-Za-z_]\\w*)\\b(?=\\s*(?:[({\"']|\\[\\[))", |
| 184 | + "name": "support.function.any-method.lua" |
159 | 185 | }, |
160 | | - |
161 | 186 | { |
162 | | - "comment": "Operators (logical)", |
163 | | - "match": "\\b(and|or|not)\\b", |
164 | | - "name": "keyword.operator.logical.lua" |
| 187 | + "match": "(?<=[^.]\\.|:)\\b([A-Za-z_]\\w*)", |
| 188 | + "name": "variable.other.lua" |
165 | 189 | }, |
166 | 190 | { |
167 | | - "comment": "Operators", |
168 | | - "match": "\\b(=|<|<=|==|~=|>=|>|\\||~|&|<<|>>|\\+|-|\\*|/|//|%|(?<!\\.)\\.{2}(?!\\.)|\\^|#)\\b", |
| 191 | + "match": "\\+|-|%|#|\\*|\\/|\\^|==?|~=|<=?|>=?|(?<!\\.)\\.{2}(?!\\.)", |
169 | 192 | "name": "keyword.operator.lua" |
170 | 193 | } |
171 | 194 | ] |
|
0 commit comments