Created
July 26, 2023 16:25
-
-
Save hello-42/08a65d3236f2e6baea3e7f3a4c90e3c4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%YAML 1.2 | |
--- | |
# http://www.sublimetext.com/docs/syntax.html | |
name: Luau | |
file_extensions: | |
- luau | |
- lua | |
scope: source.luau | |
contexts: | |
main: | |
- include: shebang | |
- include: function-declaration | |
- include: local-declaration | |
- include: for-loop | |
- include: type-alias-declaration | |
- include: expression | |
- include: comments | |
comments: | |
- match: '--\[(=*)\[' | |
push: | |
- meta_scope: comment.block.luau | |
- match: '\]\1\]' | |
pop: true | |
- match: (```lua)\s+ | |
captures: | |
1: comment.luau | |
push: | |
- meta_scope: keyword.operator.other.luau | |
- match: (```) | |
captures: | |
1: comment.luau | |
pop: true | |
- include: scope:source.luau | |
- include: doc_comment_tags | |
- match: '---' | |
push: | |
- meta_scope: comment.line.double-dash.documentation.luau | |
- match: \n | |
pop: true | |
- include: doc_comment_tags | |
- match: '--' | |
push: | |
- meta_scope: comment.line.double-dash.luau | |
- match: \n | |
pop: true | |
doc_comment_tags: | |
- match: '@\w+' | |
scope: storage.type.class.luadoc.luau | |
- match: '((?<=[\s*!\/])[\\@]param)(?:\s)+(\b\w+\b)' | |
captures: | |
1: storage.type.class.luadoc.luau | |
2: variable.parameter.luau | |
expression: | |
- include: keywords | |
- include: standard_library | |
- include: operators | |
- include: numbers | |
- include: language_constants | |
- include: strings | |
- include: identifier | |
for-loop: | |
- match: \b(for)\s+(.+?)(\bin\b|(=)) | |
captures: | |
1: keyword.control.luau | |
3: keyword.control.luau | |
4: keyword.operator.assignment.luau | |
function-declaration: | |
- match: '\b(?:(local)\s*)?(function)\s*([a-zA-Z_]\w*(?:[.:]([a-zA-Z_]\w*))*)?\s*(\<[\w\s\,\.]*\>)?\s*\(' | |
captures: | |
1: storage.modifier.local.luau | |
2: keyword.control.luau | |
3: entity.name.function.luau | |
push: | |
- meta_scope: meta.function.luau | |
- meta_content_scope: meta.parameters.luau | |
- match: '\)(?:\s*(:)\s*(.+?)(?=\s*\b(?:([^\w.,<])|\)>)\s*\w|\s*)$)?' | |
captures: | |
1: keyword.operator.type.luau | |
pop: true | |
- match: ':' | |
scope: keyword.operator.type.luau | |
- match: '(?<![:>.]\s)\b_\b' | |
scope: variable.parameter.luau | |
- match: '(?<![:>.]\s)\b([A-Z_][A-Z0-9_]*)\b' | |
scope: variable.other.constant.luau | |
- match: '(?<![:>.]\s)\b([a-zA-Z_]\w*)\b' | |
scope: variable.parameter.luau | |
- include: type_literal | |
identifier: | |
- match: '\b([A-Z_][A-Z0-9_]*)\b' | |
scope: variable.other.constant.luau | |
- match: '\b[a-zA-Z_]\w*(?=\()' | |
scope: entity.name.function.luau | |
- match: '(?<=\.)([a-zA-Z_]\w*)\b' | |
scope: variable.other.property.luau | |
- match: \b(self)\b | |
scope: variable.language.self.luau | |
- match: '\b([a-zA-Z_]\w*)\b' | |
scope: variable.other.readwrite.luau | |
- match: '\b(Axes|BrickColor|CFrame|Color3|ColorSequence|ColorSequenceKeypoint|DateTime|DockWidgetPluginGuiInfo|Faces|Instance|NumberRange|NumberSequence|NumberSequenceKeypoint|OverlapParams|PathWaypoint|PhysicalProperties|Random|Ray|RaycastParams|Rect|Region3|Region3int16|TweenInfo|UDim|UDim2|Vector2|Vector2int16|Vector3|Vector3int16)\b\.?(\b[a-zA-Z_]\w*(?=\())?' | |
captures: | |
1: support.class.luau | |
2: support.function.luau | |
interpolated-string-expression: | |
- match: '\{' | |
captures: | |
0: punctuation.definition.interpolated-string-expression.begin.luau | |
push: | |
- meta_scope: meta.template.expression.luau | |
- meta_content_scope: meta.embedded.line.luau | |
- match: '\}' | |
captures: | |
0: punctuation.definition.interpolated-string-expression.end.luau | |
pop: true | |
- include: expression | |
keywords: | |
- match: \blocal\b | |
scope: storage.modifier.local.luau | |
- match: \b(break|do|else|for|if|elseif|return|then|repeat|while|until|end|function|in|continue)\b | |
scope: keyword.control.luau | |
- match: \b(__add|__call|__concat|__div|__eq|__index|__le|__len|__lt|__metatable|__mod|__mode|__mul|__newindex|__pow|__sub|__tostring|__unm)\b | |
scope: variable.language.metamethod.luau | |
- match: (\.\.\.) | |
scope: keyword.other.unit.luau | |
language_constants: | |
- match: \btrue\b | |
scope: constant.language.boolean.true.luau | |
- match: \bfalse\b | |
scope: constant.language.boolean.false.luau | |
- match: \bnil\b | |
scope: constant.language.nil.luau | |
local-declaration: | |
- match: \b(?:(local)\s+\b) | |
captures: | |
1: storage.modifier.local.luau | |
push: | |
- match: '(?=\s*do\b|\s*[=;]|\s*$)' | |
pop: true | |
- match: ':' | |
scope: keyword.operator.type.luau | |
- include: keywords | |
- match: '(?<![:>.]\s)\b_\b' | |
scope: variable.parameter.luau | |
- match: '(?<![:>.]\s)\b([A-Z_][A-Z0-9_]*)\b' | |
scope: variable.other.constant.luau | |
- match: '(?<![:>.]\s)\b([a-zA-Z_]\w*)\b' | |
scope: variable.other.luau | |
- include: type_literal | |
numbers: | |
- match: '\b0_*[xX]_*[\da-fA-F_]*(?:[eE][\+\-]?_*\d[\d_]*(?:\.[\d_]*)?)?' | |
scope: constant.numeric.hex.luau | |
- match: '\b0_*[bB][01_]+(?:[eE][\+\-]?_*\d[\d_]*(?:\.[\d_]*)?)?' | |
scope: constant.numeric.binary.luau | |
- match: '(?:\d[\d_]*(?:\.[\d_]*)?|\.\d[\d_]*)(?:[eE][\+\-]?_*\d[\d_]*(?:\.[\d_]*)?)?' | |
scope: constant.numeric.decimal.luau | |
operators: | |
- match: (\+|-(?!-)|/|\*|%|\^) | |
scope: keyword.operator.arithmetic.luau | |
- match: \b(and|or|not)\b | |
scope: keyword.operator.logical.luau keyword.operator.wordlike.luau | |
- match: (\+=|-=|/=|\*=|%=|\^=|\.\.=|=) | |
scope: keyword.operator.assignment.luau | |
- match: (\.\.|\#) | |
scope: keyword.operator.other.luau | |
- match: (==|~=|>=|>|<=|<) | |
scope: keyword.operator.comparison.luau | |
- match: (::)\s+ | |
captures: | |
1: keyword.operator.typeassertion.luau | |
push: | |
- match: '(?=^|[;),}\]:?\-\+\>]|\|\||\&\&|\!\=\=|$|(::\s+)|(\s+\<))' | |
pop: true | |
- include: type_literal | |
shebang: | |
- match: \A(#!).*(?=$) | |
scope: comment.line.shebang.luau | |
captures: | |
1: punctuation.definition.comment.luau | |
standard_library: | |
- match: \b(assert|collectgarbage|error|getfenv|getmetatable|ipairs|loadstring|newproxy|next|pairs|pcall|print|rawequal|rawset|select|setfenv|setmetatable|tonumber|tostring|type|unpack|xpcall|require|typeof)\b | |
scope: support.function.luau | |
- match: \b(_G|_VERSION)\b | |
scope: constant.language.luau | |
- match: \b(bit32\.(?:arshift|band|bnot|bor|btest|bxor|extract|lrotate|lshift|replace|rrotate|rshift)|coroutine\.(?:create|isyieldable|resume|running|status|wrap|yield)|debug\.(?:loadmodule|profilebegin|profileend|traceback)|math\.(?:abs|acos|asin|atan|atan2|ceil|clamp|cos|cosh|deg|exp|floor|fmod|frexp|ldexp|log|log10|max|min|modf|noise|pow|rad|random|randomseed|round|sign|sin|sinh|sqrt|tan|tanh)|os\.(?:clock|date|difftime|time)|string\.(?:byte|char|find|format|gmatch|gsub|len|lower|match|pack|packsize|rep|reverse|split|sub|unpack|upper)|table\.(?:concat|create|find|foreach|foreachi|getn|insert|maxn|move|pack|remove|sort|unpack|clear)|task\.(?:spawn|synchronize|desynchronize|wait|defer|delay)|utf8\.(?:char|codepoint|codes|graphemes|len|nfcnormalize|nfdnormalize|offset))\b | |
scope: support.function.luau | |
- match: \b(bit32|coroutine|debug|math(\.(huge|pi))?|os|string|table|task|utf8(\.charpattern)?)\b | |
scope: support.constant.luau | |
- match: \b(delay|DebuggerManager|elapsedTime|PluginManager|printidentity|settings|spawn|stats|tick|time|UserSettings|version|wait|warn)\b | |
scope: support.function.luau | |
- match: '\b(game|plugin|shared|script|workspace|Enum(?:\.\w+){0,2})\b' | |
scope: constant.language.luau | |
string_escape: | |
- match: '\\[abfnrtvz''"`{\\]' | |
scope: constant.character.escape.luau | |
- match: '\\\d{1,3}' | |
scope: constant.character.escape.luau | |
- match: '\\x[0-9a-fA-F]{2}' | |
scope: constant.character.escape.luau | |
- match: '\\u\{[0-9a-fA-F]*\}' | |
scope: constant.character.escape.luau | |
strings: | |
- match: '"' | |
push: | |
- meta_scope: string.quoted.double.luau | |
- match: '"' | |
pop: true | |
- include: string_escape | |
- match: "'" | |
push: | |
- meta_scope: string.quoted.single.luau | |
- match: "'" | |
pop: true | |
- include: string_escape | |
- match: '\[(=*)\[' | |
push: | |
- meta_scope: string.other.multiline.luau | |
- match: '\]\1\]' | |
pop: true | |
- match: '`' | |
push: | |
- meta_scope: string.interpolated.luau | |
- match: '`' | |
pop: true | |
- include: interpolated-string-expression | |
- include: string_escape | |
type-alias-declaration: | |
- match: '\b(?:(export)\s+)?(type)\s+([^=]+)\s*(=)' | |
captures: | |
1: storage.modifier.visibility.luau | |
2: storage.type.luau | |
4: keyword.operator.assignment.luau | |
push: | |
- match: (?=\s*$)|(?=\s*;) | |
pop: true | |
- include: type_literal | |
type_literal: | |
- match: '([\?|\||\&])' | |
scope: keyword.operator.type.luau | |
- match: (->) | |
scope: keyword.operator.type.luau | |
- match: \b(typeof)\b\s*\( | |
captures: | |
1: support.function.luau | |
push: | |
- match: '\)(?![.,:\)])' | |
pop: true | |
- include: expression | |
- match: \b(nil|string|number|boolean|thread|userdata|symbol|any)\b | |
scope: support.type.primitive.luau | |
- include: language_constants | |
- match: '\b([a-zA-Z]\w*)\b(<)' | |
captures: | |
1: entity.name.type.luau | |
2: keyword.operator.type.luau | |
push: | |
- meta_content_scope: meta.parameter.type.variable.luau | |
- match: (>) | |
captures: | |
1: keyword.operator.type.luau | |
pop: true | |
- include: type_literal | |
- match: '\b([a-zA-Z]\w*)\b' | |
scope: entity.name.type.luau | |
- match: '\{' | |
push: | |
- match: '\}' | |
pop: true | |
- match: ':' | |
scope: keyword.operator.type.luau | |
- match: '\[' | |
push: | |
- match: '\]' | |
pop: true | |
- include: type_literal | |
- match: '(?<!:\*|->\s)\b([a-zA-Z_]\w)\b(?=:)' | |
scope: variable.property.luau | |
- include: type_literal | |
- match: '(\s*\<[\w\s\,]*\>\s*)?\(' | |
push: | |
- match: \) | |
pop: true | |
- match: '([a-zA-Z_]\w*)\s*(:)' | |
scope: variable.parameter.luau | |
captures: | |
1: variable.parameter.luau | |
2: keyword.operator.type.luau | |
- include: type_literal | |
- include: strings | |
- include: comments |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment