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