forked from Aviarita/LuaExtended
-
Notifications
You must be signed in to change notification settings - Fork 0
/
LuaExtended.sublime-syntax
173 lines (173 loc) · 5.91 KB
/
LuaExtended.sublime-syntax
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
%YAML 1.2
---
name: LuaExtended # by viluon
comment: "LuaExtended Syntax: version 0.1"
file_extensions:
- lua
- luae
- ext.lua
- extended.lua
scope: source.luae
variables:
number: '(?<![\d.])\b0[xX][a-fA-F\d\.]+([pP][\-\+]?\d+)?|\b\d+(\.\d+)?([eE]-?\d+)?|\.\d+([eE]-?\d+)?'
contexts:
main:
- match: '\b(function)\s+'
scope: meta.function.lua
captures:
1: keyword.control.lua
push: function_def_name
- match: '{{number}}'
scope: constant.numeric.lua
- match: "'"
captures:
0: punctuation.definition.string.begin.lua
scope: string.quoted.single.lua
push: string_quoted_single
- match: '"'
captures:
0: punctuation.definition.string.begin.lua
push: string_quoted_double
- match: '(?<!--)\[(=*)\['
captures:
0: punctuation.definition.string.begin.lua
push: string_quoted_multiline
- match: '--\[(=*)\['
captures:
0: punctuation.definition.comment.lua
push: comment_block
- match: '(--)(?!\[\[).*$\n?'
scope: comment.line.double-dash.lua
captures:
1: punctuation.definition.comment.lua
- match: \b(break|do|else|for|if|elseif|return|then|repeat|while|until|end|function|local|in)\b
scope: keyword.control.lua
- match: '(?<![^.]\.|:)\b(false|nil|true|_G|_VERSION|math\.(pi|huge))\b|(?<![.])\.{3}(?!\.)'
scope: constant.language.lua
- match: '(?<![^.]\.|:)\b(self)\b'
scope: variable.language.self.lua
- match: '(?<![^.]\.|:)\b(error)\s*(?=[\(''"])'
captures:
1: support.function.lua
2: none
push: error_call_start
- 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(?=[( {"''\[])'
scope: support.function.lua
- 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(?=[( {"''\[])'
scope: support.function.library.lua
- match: \b(and|or|not)\b
scope: keyword.operator.lua
- match: '\+|-|%|#|\*|\/|\^|==?|~=|<=?|>=?|(?<!\.)\.{2}(?!\.)'
scope: keyword.operator.lua
- match: '([a-zA-Z_.:]+[.:])?([a-zA-Z_]\w*)\s*(?=\(|\"|''|\[(\=*)\[|\{)'
captures:
2: variable.function.lua
function_def_name:
- match: '([a-zA-Z_.:]+[.:])?([a-zA-Z_]\w*)\s*'
captures:
1: entity.name.function.scope.lua
2: entity.name.function.lua
- match: '(\()'
captures:
1: punctuation.definition.parameters.begin.lua
set: function_def_args
function_def_args:
- match: '([^)]*)'
captures:
1: variable.parameter.function.lua
- match: '(\))'
captures:
1: punctuation.definition.parameters.end.lua
pop: true
error_call_start:
- match: "'"
captures:
0: punctuation.definition.string.begin.lua
set: error_string_quoted_single
- match: '"'
captures:
0: punctuation.definition.string.begin.lua
set: error_string_quoted_double
- match: '(?<!--)\[(=*)\['
captures:
0: punctuation.definition.string.begin.lua
set: error_string_quoted_multiline
- match: '\('
captures:
0: none
set: error_parens
error_parens:
- match: '\('
captures:
0: none
push: error_parens
- match: '\)'
pop: true
- match: "'"
captures:
0: punctuation.definition.string.begin.lua
push: error_string_quoted_single
- match: '"'
captures:
0: punctuation.definition.string.begin.lua
push: error_string_quoted_double
- match: '(?<!--)\[(=*)\['
captures:
0: punctuation.definition.string.begin.lua
push: error_string_quoted_multiline
- include: main
error_string_quoted_single:
- meta_scope: sublimelinter.mark.error
- match: "'"
captures:
0: punctuation.definition.string.end.lua
pop: true
- include: string
error_string_quoted_double:
- meta_scope: sublimelinter.mark.error
- match: '"'
captures:
0: punctuation.definition.string.end.lua
pop: true
- include: string
error_string_quoted_multiline:
- meta_scope: sublimelinter.mark.error
- match: '\]\1\]'
captures:
0: punctuation.definition.string.end.lua
pop: true
- include: string
string_quoted_single:
- meta_scope: string.quoted.single.lua
- match: "'"
captures:
0: punctuation.definition.string.end.lua
pop: true
- include: string
string_quoted_double:
- meta_scope: string.quoted.double.lua
- match: '"'
captures:
0: punctuation.definition.string.end.lua
pop: true
- include: string
string_quoted_multiline:
- meta_scope: string.quoted.other.multiline.lua
- match: '\]\1\]'
captures:
0: punctuation.definition.string.end.lua
pop: true
- include: string
comment_block:
- meta_scope: comment.block.lua
- match: '\]\1\]'
captures:
0: punctuation.definition.comment.lua
pop: true
string:
- match: '\\([abfnrtv\\"'']|\r?\n|\n\r?|\d\d?\d?)'
scope: constant.character.escape.lua
- match: '\\[xX][0-9a-fA-F][0-9a-fA-F]'
scope: constant.character.escape.lua
- match: '\\u\{[0-9a-fA-F]{,7}\}'
scope: constant.character.escape.lua