Path: blob/main/extensions/lua/syntaxes/lua.tmLanguage.json
3314 views
{1"information_for_contributors": [2"This file has been converted from https://github.com/sumneko/lua.tmbundle/blob/master/Syntaxes/Lua.plist",3"If you want to provide a fix or improvement, please create a pull request against the original repository.",4"Once accepted there, we are happy to receive an update request."5],6"version": "https://github.com/sumneko/lua.tmbundle/commit/1483add845ebfb3e1e631fe372603e5fed2cdd42",7"name": "Lua",8"scopeName": "source.lua",9"patterns": [10{11"begin": "\\b(?:(local)\\s+)?(function)\\b(?![,:])",12"beginCaptures": {13"1": {14"name": "keyword.local.lua"15},16"2": {17"name": "keyword.control.lua"18}19},20"end": "(?<=[\\)\\-{}\\[\\]\"'])",21"name": "meta.function.lua",22"patterns": [23{24"include": "#comment"25},26{27"begin": "(\\()",28"beginCaptures": {29"1": {30"name": "punctuation.definition.parameters.begin.lua"31}32},33"end": "(\\))|(?=[\\-\\.{}\\[\\]\"'])",34"endCaptures": {35"1": {36"name": "punctuation.definition.parameters.finish.lua"37}38},39"name": "meta.parameter.lua",40"patterns": [41{42"include": "#comment"43},44{45"match": "[a-zA-Z_][a-zA-Z0-9_]*",46"name": "variable.parameter.function.lua"47},48{49"match": ",",50"name": "punctuation.separator.arguments.lua"51},52{53"begin": ":",54"beginCaptures": {55"0": {56"name": "punctuation.separator.arguments.lua"57}58},59"end": "(?=[\\),])",60"patterns": [61{62"include": "#emmydoc.type"63}64]65}66]67},68{69"match": "\\b([a-zA-Z_][a-zA-Z0-9_]*)\\b\\s*(?=:)",70"name": "entity.name.class.lua"71},72{73"match": "\\b([a-zA-Z_][a-zA-Z0-9_]*)\\b",74"name": "entity.name.function.lua"75}76]77},78{79"match": "(?<![\\w\\d.])0[xX][0-9A-Fa-f]+(\\.[0-9A-Fa-f]*)?([eE]-?\\d*)?([pP][-+]\\d+)?",80"name": "constant.numeric.float.hexadecimal.lua"81},82{83"match": "(?<![\\w\\d.])0[xX]\\.[0-9A-Fa-f]+([eE]-?\\d*)?([pP][-+]\\d+)?",84"name": "constant.numeric.float.hexadecimal.lua"85},86{87"match": "(?<![\\w\\d.])0[xX][0-9A-Fa-f]+(?![pPeE.0-9])",88"name": "constant.numeric.integer.hexadecimal.lua"89},90{91"match": "(?<![\\w\\d.])\\d+(\\.\\d*)?([eE]-?\\d*)?",92"name": "constant.numeric.float.lua"93},94{95"match": "(?<![\\w\\d.])\\.\\d+([eE]-?\\d*)?",96"name": "constant.numeric.float.lua"97},98{99"match": "(?<![\\w\\d.])\\d+(?![pPeE.0-9])",100"name": "constant.numeric.integer.lua"101},102{103"include": "#string"104},105{106"captures": {107"1": {108"name": "punctuation.definition.comment.lua"109}110},111"match": "\\A(#!).*$\\n?",112"name": "comment.line.shebang.lua"113},114{115"include": "#comment"116},117{118"captures": {119"1": {120"name": "keyword.control.goto.lua"121},122"2": {123"name": "string.tag.lua"124}125},126"match": "\\b(goto)\\s+([a-zA-Z_][a-zA-Z0-9_]*)"127},128{129"captures": {130"1": {131"name": "punctuation.section.embedded.begin.lua"132},133"2": {134"name": "punctuation.section.embedded.end.lua"135}136},137"match": "(::)\\s*[a-zA-Z_][a-zA-Z0-9_]*\\s*(::)",138"name": "string.tag.lua"139},140{141"match": "<\\s*(const|close)\\s*>",142"captures": {143"0": {144"name": "storage.type.attribute.lua"145}146}147},148{149"match": "\\<[a-zA-Z_\\*][a-zA-Z0-9_\\.\\*\\-]*\\>",150"name": "storage.type.generic.lua"151},152{153"match": "\\b(break|do|else|for|if|elseif|goto|return|then|repeat|while|until|end|in)\\b",154"name": "keyword.control.lua"155},156{157"match": "\\b(local)\\b",158"name": "keyword.local.lua"159},160{161"match": "\\b(function)\\b(?![,:])",162"name": "keyword.control.lua"163},164{165"match": "(?<![^.]\\.|:)\\b(false|nil(?!:)|true|_ENV|_G|_VERSION|math\\.(pi|huge|maxinteger|mininteger)|utf8\\.charpattern|io\\.(stdin|stdout|stderr)|package\\.(config|cpath|loaded|loaders|path|preload|searchers))\\b|(?<![.])\\.{3}(?!\\.)",166"name": "constant.language.lua"167},168{169"match": "(?<![^.]\\.|:)\\b(self)\\b",170"name": "variable.language.self.lua"171},172{173"match": "(?<![^.]\\.|:)\\b(assert|collectgarbage|dofile|error|getfenv|getmetatable|ipairs|load|loadfile|loadstring|module|next|pairs|pcall|print|rawequal|rawget|rawlen|rawset|require|select|setfenv|setmetatable|tonumber|tostring|type|unpack|xpcall)\\b(?!\\s*=(?!=))",174"name": "support.function.lua"175},176{177"match": "(?<![^.]\\.|:)\\b(async)\\b(?!\\s*=(?!=))",178"name": "entity.name.tag.lua"179},180{181"match": "(?<![^.]\\.|:)\\b(coroutine\\.(create|isyieldable|close|resume|running|status|wrap|yield)|string\\.(byte|char|dump|find|format|gmatch|gsub|len|lower|match|pack|packsize|rep|reverse|sub|unpack|upper)|table\\.(concat|insert|maxn|move|pack|remove|sort|unpack)|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?|tointeger|type)|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\\.(loadlib|seeall|searchpath)|debug\\.(debug|[gs]etfenv|[gs]ethook|getinfo|[gs]etlocal|[gs]etmetatable|getregistry|[gs]etupvalue|[gs]etuservalue|set[Cc]stacklimit|traceback|upvalueid|upvaluejoin)|bit32\\.(arshift|band|bnot|bor|btest|bxor|extract|replace|lrotate|lshift|rrotate|rshift)|utf8\\.(char|codes|codepoint|len|offset))\\b(?!\\s*=(?!=))",182"name": "support.function.library.lua"183},184{185"match": "\\b(and|or|not|\\|\\||\\&\\&|\\!)\\b",186"name": "keyword.operator.lua"187},188{189"match": "\\b([a-zA-Z_][a-zA-Z0-9_]*)\\b(?=\\s*(?:[({\"']|\\[\\[))",190"name": "support.function.any-method.lua"191},192{193"match": "\\b([a-zA-Z_][a-zA-Z0-9_]*)\\b(?=\\s*\\??:)",194"name": "entity.name.class.lua"195},196{197"match": "(?<=[^.]\\.|:)\\b([a-zA-Z_][a-zA-Z0-9_]*)\\b(?!\\s*=\\s*\\b(function)\\b)",198"name": "entity.other.attribute.lua"199},200{201"match": "\\b([a-zA-Z_][a-zA-Z0-9_]*)\\b(?!\\s*=\\s*\\b(function)\\b)",202"name": "variable.other.lua"203},204{205"match": "\\b([a-zA-Z_][a-zA-Z0-9_]*)\\b(?=\\s*=\\s*\\b(function)\\b)",206"name": "entity.name.function.lua"207},208{209"match": "\\+|-|%|#|\\*|\\/|\\^|==?|~=|!=|<=?|>=?|(?<!\\.)\\.{2}(?!\\.)",210"name": "keyword.operator.lua"211}212],213"repository": {214"escaped_char": {215"patterns": [216{217"match": "\\\\[abfnrtv\\\\\"'\\n]",218"name": "constant.character.escape.lua"219},220{221"match": "\\\\z[\\n\\t ]*",222"name": "constant.character.escape.lua"223},224{225"match": "\\\\\\d{1,3}",226"name": "constant.character.escape.byte.lua"227},228{229"match": "\\\\x[0-9A-Fa-f][0-9A-Fa-f]",230"name": "constant.character.escape.byte.lua"231},232{233"match": "\\\\u\\{[0-9A-Fa-f]+\\}",234"name": "constant.character.escape.unicode.lua"235},236{237"match": "\\\\.",238"name": "invalid.illegal.character.escape.lua"239}240]241},242"string": {243"patterns": [244{245"begin": "'",246"beginCaptures": {247"0": {248"name": "punctuation.definition.string.begin.lua"249}250},251"end": "'[ \\t]*|(?=\\n)",252"endCaptures": {253"0": {254"name": "punctuation.definition.string.end.lua"255}256},257"name": "string.quoted.single.lua",258"patterns": [259{260"include": "#escaped_char"261}262]263},264{265"begin": "\"",266"beginCaptures": {267"0": {268"name": "punctuation.definition.string.begin.lua"269}270},271"end": "\"[ \\t]*|(?=\\n)",272"endCaptures": {273"0": {274"name": "punctuation.definition.string.end.lua"275}276},277"name": "string.quoted.double.lua",278"patterns": [279{280"include": "#escaped_char"281}282]283},284{285"begin": "`",286"beginCaptures": {287"0": {288"name": "punctuation.definition.string.begin.lua"289}290},291"end": "`[ \\t]*|(?=\\n)",292"endCaptures": {293"0": {294"name": "punctuation.definition.string.end.lua"295}296},297"name": "string.quoted.double.lua"298},299{300"begin": "(?<=\\.cdef)\\s*(\\[(=*)\\[)",301"beginCaptures": {302"0": {303"name": "string.quoted.other.multiline.lua"304},305"1": {306"name": "punctuation.definition.string.begin.lua"307}308},309"contentName": "meta.embedded.lua",310"end": "(\\]\\2\\])[ \\t]*",311"endCaptures": {312"0": {313"name": "string.quoted.other.multiline.lua"314},315"1": {316"name": "punctuation.definition.string.end.lua"317}318},319"patterns": [320{321"include": "source.c"322}323]324},325{326"begin": "(?<!--)\\[(=*)\\[",327"beginCaptures": {328"0": {329"name": "punctuation.definition.string.begin.lua"330}331},332"end": "\\]\\1\\][ \\t]*",333"endCaptures": {334"0": {335"name": "punctuation.definition.string.end.lua"336}337},338"name": "string.quoted.other.multiline.lua"339}340]341},342"comment": {343"patterns": [344{345"begin": "(^[ \\t]+)?(?=--)",346"beginCaptures": {347"1": {348"name": "punctuation.whitespace.comment.leading.lua"349}350},351"end": "(?!\\G)((?!^)[ \\t]+\\n)?",352"endCaptures": {353"1": {354"name": "punctuation.whitespace.comment.trailing.lua"355}356},357"patterns": [358{359"begin": "--\\[(=*)\\[@@@",360"beginCaptures": {361"0": {362"name": "punctuation.definition.comment.begin.lua"363}364},365"end": "(--)?\\]\\1\\]",366"endCaptures": {367"0": {368"name": "punctuation.definition.comment.end.lua"369}370},371"name": "",372"patterns": [373{374"include": "source.lua"375}376]377},378{379"begin": "--\\[(=*)\\[",380"beginCaptures": {381"0": {382"name": "punctuation.definition.comment.begin.lua"383}384},385"end": "(--)?\\]\\1\\]",386"endCaptures": {387"0": {388"name": "punctuation.definition.comment.end.lua"389}390},391"name": "comment.block.lua",392"patterns": [393{394"include": "#emmydoc"395},396{397"include": "#ldoc_tag"398}399]400},401{402"begin": "----",403"beginCaptures": {404"0": {405"name": "punctuation.definition.comment.lua"406}407},408"end": "\\n",409"name": "comment.line.double-dash.lua"410},411{412"begin": "---",413"beginCaptures": {414"0": {415"name": "punctuation.definition.comment.lua"416}417},418"end": "\\n",419"name": "comment.line.double-dash.documentation.lua",420"patterns": [421{422"include": "#emmydoc"423},424{425"include": "#ldoc_tag"426}427]428},429{430"begin": "--",431"beginCaptures": {432"0": {433"name": "punctuation.definition.comment.lua"434}435},436"end": "\\n",437"name": "comment.line.double-dash.lua",438"patterns": [439{440"include": "#ldoc_tag"441}442]443}444]445},446{447"begin": "\\/\\*",448"beginCaptures": {449"0": {450"name": "punctuation.definition.comment.begin.lua"451}452},453"end": "\\*\\/",454"endCaptures": {455"0": {456"name": "punctuation.definition.comment.end.lua"457}458},459"name": "comment.block.lua",460"patterns": [461{462"include": "#emmydoc"463},464{465"include": "#ldoc_tag"466}467]468}469]470},471"emmydoc": {472"patterns": [473{474"begin": "(?<=---)[ \\t]*@class",475"beginCaptures": {476"0": {477"name": "storage.type.annotation.lua"478}479},480"end": "(?=[\\n@#])",481"patterns": [482{483"match": "\\b([a-zA-Z_\\*][a-zA-Z0-9_\\.\\*\\-]*)",484"name": "support.class.lua"485},486{487"match": ":|,",488"name": "keyword.operator.lua"489}490]491},492{493"begin": "(?<=---)[ \\t]*@enum",494"beginCaptures": {495"0": {496"name": "storage.type.annotation.lua"497}498},499"end": "(?=[\\n@#])",500"patterns": [501{502"begin": "\\b([a-zA-Z_\\*][a-zA-Z0-9_\\.\\*\\-]*)",503"beginCaptures": {504"0": {505"name": "variable.lua"506}507},508"end": "(?=\\n)"509}510]511},512{513"begin": "(?<=---)[ \\t]*@type",514"beginCaptures": {515"0": {516"name": "storage.type.annotation.lua"517}518},519"end": "(?=[\\n@#])",520"patterns": [521{522"include": "#emmydoc.type"523}524]525},526{527"begin": "(?<=---)[ \\t]*@alias",528"beginCaptures": {529"0": {530"name": "storage.type.annotation.lua"531}532},533"end": "(?=[\\n@#])",534"patterns": [535{536"begin": "\\b([a-zA-Z_\\*][a-zA-Z0-9_\\.\\*\\-]*)",537"beginCaptures": {538"0": {539"name": "variable.lua"540}541},542"end": "(?=[\\n#])",543"patterns": [544{545"include": "#emmydoc.type"546}547]548}549]550},551{552"begin": "(?<=---)[ \\t]*(@operator)\\s*(\\b[a-z]+)?",553"beginCaptures": {554"1": {555"name": "storage.type.annotation.lua"556},557"2": {558"name": "support.function.library.lua"559}560},561"end": "(?=[\\n@#])",562"patterns": [563{564"include": "#emmydoc.type"565}566]567},568{569"begin": "(?<=---)[ \\t]*@cast",570"beginCaptures": {571"0": {572"name": "storage.type.annotation.lua"573}574},575"end": "(?=[\\n@#])",576"patterns": [577{578"begin": "\\b([a-zA-Z_\\*][a-zA-Z0-9_\\.\\*\\-]*)",579"beginCaptures": {580"0": {581"name": "variable.other.lua"582}583},584"end": "(?=\\n)",585"patterns": [586{587"include": "#emmydoc.type"588},589{590"match": "([+-|])",591"name": "keyword.operator.lua"592}593]594}595]596},597{598"begin": "(?<=---)[ \\t]*@param",599"beginCaptures": {600"0": {601"name": "storage.type.annotation.lua"602}603},604"end": "(?=[\\n@#])",605"patterns": [606{607"begin": "\\b([a-zA-Z_][a-zA-Z0-9_]*)\\b(\\??)",608"beginCaptures": {609"1": {610"name": "entity.name.variable.lua"611},612"2": {613"name": "keyword.operator.lua"614}615},616"end": "(?=[\\n#])",617"patterns": [618{619"include": "#emmydoc.type"620}621]622}623]624},625{626"begin": "(?<=---)[ \\t]*@return",627"beginCaptures": {628"0": {629"name": "storage.type.annotation.lua"630}631},632"end": "(?=[\\n@#])",633"patterns": [634{635"match": "\\?",636"name": "keyword.operator.lua"637},638{639"include": "#emmydoc.type"640}641]642},643{644"begin": "(?<=---)[ \\t]*@field",645"beginCaptures": {646"0": {647"name": "storage.type.annotation.lua"648}649},650"end": "(?=[\\n@#])",651"patterns": [652{653"begin": "(\\b([a-zA-Z_][a-zA-Z0-9_]*)\\b|(\\[))(\\??)",654"beginCaptures": {655"2": {656"name": "entity.name.variable.lua"657},658"3": {659"name": "keyword.operator.lua"660}661},662"end": "(?=[\\n#])",663"patterns": [664{665"include": "#string"666},667{668"include": "#emmydoc.type"669},670{671"match": "\\]",672"name": "keyword.operator.lua"673}674]675}676]677},678{679"begin": "(?<=---)[ \\t]*@generic",680"beginCaptures": {681"0": {682"name": "storage.type.annotation.lua"683}684},685"end": "(?=[\\n@#])",686"patterns": [687{688"begin": "\\b([a-zA-Z_][a-zA-Z0-9_]*)\\b",689"beginCaptures": {690"0": {691"name": "storage.type.generic.lua"692}693},694"end": "(?=\\n)|(,)",695"endCaptures": {696"0": {697"name": "keyword.operator.lua"698}699},700"patterns": [701{702"match": ":",703"name": "keyword.operator.lua"704},705{706"include": "#emmydoc.type"707}708]709}710]711},712{713"begin": "(?<=---)[ \\t]*@vararg",714"beginCaptures": {715"0": {716"name": "storage.type.annotation.lua"717}718},719"end": "(?=[\\n@#])",720"patterns": [721{722"include": "#emmydoc.type"723}724]725},726{727"begin": "(?<=---)[ \\t]*@overload",728"beginCaptures": {729"0": {730"name": "storage.type.annotation.lua"731}732},733"end": "(?=[\\n@#])",734"patterns": [735{736"include": "#emmydoc.type"737}738]739},740{741"begin": "(?<=---)[ \\t]*@deprecated",742"beginCaptures": {743"0": {744"name": "storage.type.annotation.lua"745}746},747"end": "(?=[\\n@#])"748},749{750"begin": "(?<=---)[ \\t]*@meta",751"beginCaptures": {752"0": {753"name": "storage.type.annotation.lua"754}755},756"end": "(?=[\\n@#])"757},758{759"begin": "(?<=---)[ \\t]*@private",760"beginCaptures": {761"0": {762"name": "storage.type.annotation.lua"763}764},765"end": "(?=[\\n@#])"766},767{768"begin": "(?<=---)[ \\t]*@protected",769"beginCaptures": {770"0": {771"name": "storage.type.annotation.lua"772}773},774"end": "(?=[\\n@#])"775},776{777"begin": "(?<=---)[ \\t]*@package",778"beginCaptures": {779"0": {780"name": "storage.type.annotation.lua"781}782},783"end": "(?=[\\n@#])"784},785{786"begin": "(?<=---)[ \\t]*@version",787"beginCaptures": {788"0": {789"name": "storage.type.annotation.lua"790}791},792"end": "(?=[\\n@#])",793"patterns": [794{795"match": "\\b(5\\.1|5\\.2|5\\.3|5\\.4|JIT)\\b",796"name": "support.class.lua"797},798{799"match": ",|\\>|\\<",800"name": "keyword.operator.lua"801}802]803},804{805"begin": "(?<=---)[ \\t]*@see",806"beginCaptures": {807"0": {808"name": "storage.type.annotation.lua"809}810},811"end": "(?=[\\n@#])",812"patterns": [813{814"match": "\\b([a-zA-Z_\\*][a-zA-Z0-9_\\.\\*\\-]*)",815"name": "support.class.lua"816},817{818"match": "#",819"name": "keyword.operator.lua"820}821]822},823{824"begin": "(?<=---)[ \\t]*@diagnostic",825"beginCaptures": {826"0": {827"name": "storage.type.annotation.lua"828}829},830"end": "(?=[\\n@#])",831"patterns": [832{833"begin": "([a-zA-Z_\\-0-9]+)[ \\t]*(:)?",834"beginCaptures": {835"1": {836"name": "keyword.other.unit"837},838"2": {839"name": "keyword.operator.unit"840}841},842"end": "(?=\\n)",843"patterns": [844{845"match": "\\b([a-zA-Z_\\*][a-zA-Z0-9_\\-]*)",846"name": "support.class.lua"847},848{849"match": ",",850"name": "keyword.operator.lua"851}852]853}854]855},856{857"begin": "(?<=---)[ \\t]*@module",858"beginCaptures": {859"0": {860"name": "storage.type.annotation.lua"861}862},863"end": "(?=[\\n@#])",864"patterns": [865{866"include": "#string"867}868]869},870{871"match": "(?<=---)[ \\t]*@(async|nodiscard)",872"name": "storage.type.annotation.lua"873},874{875"begin": "(?<=---)\\|\\s*[\\>\\+]?",876"beginCaptures": {877"0": {878"name": "storage.type.annotation.lua"879}880},881"end": "(?=[\\n@#])",882"patterns": [883{884"include": "#string"885}886]887}888]889},890"emmydoc.type": {891"patterns": [892{893"begin": "\\bfun\\b",894"beginCaptures": {895"0": {896"name": "keyword.control.lua"897}898},899"end": "(?=[\\s#])",900"patterns": [901{902"match": "[\\(\\),:\\?][ \\t]*",903"name": "keyword.operator.lua"904},905{906"match": "([a-zA-Z_][a-zA-Z0-9_\\.\\*\\[\\]\\<\\>\\,\\-]*)(?<!,)[ \\t]*(?=\\??:)",907"name": "entity.name.variable.lua"908},909{910"include": "#emmydoc.type"911},912{913"include": "#string"914}915]916},917{918"match": "\\<[a-zA-Z_\\*][a-zA-Z0-9_\\.\\*\\-]*\\>",919"name": "storage.type.generic.lua"920},921{922"match": "\\basync\\b",923"name": "entity.name.tag.lua"924},925{926"match": "[\\{\\}\\:\\,\\?\\|\\`][ \\t]*",927"name": "keyword.operator.lua"928},929{930"begin": "(?=[a-zA-Z_\\.\\*\"'\\[])",931"end": "(?=[\\s\\)\\,\\?\\:\\}\\|#])",932"patterns": [933{934"match": "([a-zA-Z0-9_\\.\\*\\[\\]\\<\\>\\,\\-]+)(?<!,)[ \\t]*",935"name": "support.type.lua"936},937{938"match": "(\\.\\.\\.)[ \\t]*",939"name": "constant.language.lua"940},941{942"include": "#string"943}944]945}946]947},948"ldoc_tag": {949"match": "\\G[ \\t]*(@)(alias|annotation|author|charset|class|classmod|comment|constructor|copyright|description|example|export|factory|field|file|fixme|function|include|lfunction|license|local|module|name|param|pragma|private|raise|release|return|script|section|see|set|static|submodule|summary|tfield|thread|tparam|treturn|todo|topic|type|usage|warning|within)\\b",950"captures": {951"1": {952"name": "punctuation.definition.block.tag.ldoc"953},954"2": {955"name": "storage.type.class.ldoc"956}957}958}959}960}961962