X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=runtime%2Fsyntax%2Flua.yaml;h=934f6a317508b665647314dd5e2b404c63393c35;hb=54c23cae72d7237bc898a59f79aad0acffdf0ffe;hp=0b485d5bddec8ddaff5591221f7197b41401431a;hpb=2fcb40d5a9f505e39519fd5c32e3754cd0e83dd5;p=micro.git diff --git a/runtime/syntax/lua.yaml b/runtime/syntax/lua.yaml index 0b485d5b..934f6a31 100644 --- a/runtime/syntax/lua.yaml +++ b/runtime/syntax/lua.yaml @@ -4,7 +4,7 @@ detect: filename: "\\.lua$" rules: - - statement: "\\b(do|end|while|repeat|until|if|elseif|then|else|for|in|function|local|return)\\b" + - statement: "\\b(do|end|while|break|repeat|until|if|elseif|then|else|for|in|function|local|return)\\b" - statement: "\\b(not|and|or)\\b" - statement: "\\b(debug|string|math|table|io|coroutine|os|utf8|bit32)\\b\\." - statement: "\\b(_ENV|_G|_VERSION|assert|collectgarbage|dofile|error|getfenv|getmetatable|ipairs|load|loadfile|module|next|pairs|pcall|print|rawequal|rawget|rawlen|rawset|require|select|setfenv|setmetatable|tonumber|tostring|type|unpack|xpcall)\\s*\\(" @@ -18,21 +18,25 @@ rules: - identifier: "coroutine\\.\\b(create|isyieldable|resume|running|status|wrap|yield)\\b" - identifier: "debug\\.\\b(debug|getfenv|gethook|getinfo|getlocal|getmetatable|getregistry|getupvalue|getuservalue|setfenv|sethook|setlocal|setmetatable|setupvalue|setuservalue|traceback|upvalueid|upvaluejoin)\\b" - identifier: "bit32\\.\\b(arshift|band|bnot|bor|btest|bxor|extract|replace|lrotate|lshift|rrotate|rshift)\\b" - - identifier: "\\:\\b(close|flush|lines|read|seek|setvbuf|write)\\b" + - identifier: "\\:\\b(close|flush|lines|read|seek|setvbuf|write|byte|char|dump|find|format|gmatch|gsub|len|lower|match|pack|packsize|rep|reverse|sub|unpack|upper)\\b" + - identifier: "\\b(self|arg)\\b" - constant: "\\b(false|nil|true)\\b" - statement: "(\\b(dofile|require|include)|%q|%!|%Q|%r|%x)\\b" - constant.number: "\\b([0-9]+)\\b" - - symbol: "(\\(|\\)|\\[|\\]|\\{|\\}|\\*\\*|\\*|/|%|\\+|-|\\^|>|>=|<|<=|~=|=|\\.\\.)" + - symbol.brackets: "[(){}\\[\\]]" + - symbol: "(\\*|//|/|%|\\+|-|\\^|>|>=|<|<=|~=|=|[\\.]{2,3}|#)" - constant.string: start: "\"" end: "\"" + skip: "\\\\." rules: - constant.specialChar: "\\\\." - constant.string: start: "'" end: "'" + skip: "\\\\." rules: - constant.specialChar: "\\\\." @@ -42,19 +46,71 @@ rules: rules: - constant.specialChar: "\\\\." +# support first few lengths of "long brackets" explicitly +# brackets longer than that will give false positives + + - constant.string: + start: "\\[=\\[" + end: "\\]=\\]" + rules: + - constant.specialChar: "\\\\." + + - constant.string: + start: "\\[==\\[" + end: "\\]==\\]" + rules: + - constant.specialChar: "\\\\." + + - constant.string: + start: "\\[===\\[" + end: "\\]===\\]" + rules: + - constant.specialChar: "\\\\." + + - constant.string: + start: "\\[====+\\[" + end: "\\]====+\\]" + rules: + - constant.specialChar: "\\\\." + - special: "\\\\[0-7][0-7][0-7]|\\\\x[0-9a-fA-F][0-9a-fA-F]|\\\\[abefnrs]|(\\\\c|\\\\C-|\\\\M-|\\\\M-\\\\C-)." - - comment: - start: "#" - end: "$" - rules: [] + - comment.block: + start: "\\-\\-\\[\\[" + end: "\\]\\]" + rules: + - todo: "(TODO|NOTE|FIXME):?" + +# support long brackets, same as with multiline strings + + - comment.block: + start: "\\-\\-\\[=\\[" + end: "\\]=\\]" + rules: + - todo: "(TODO|NOTE|FIXME):?" + + - comment.block: + start: "\\-\\-\\[==\\[" + end: "\\]==\\]" + rules: + - todo: "(TODO|NOTE|FIXME):?" + + - comment.block: + start: "\\-\\-\\[===\\[" + end: "\\]===\\]" + rules: + - todo: "(TODO|NOTE|FIXME):?" + + - comment.block: + start: "\\-\\-\\[====+\\[" + end: "\\]====+\\]" + rules: + - todo: "(TODO|NOTE|FIXME):?" + +# this has to go after block comment or block comment does not work - comment: start: "\\-\\-" end: "$" - rules: [] - - - comment: - start: "\\-\\-\\[\\[" - end: "\\]\\]" - rules: [] + rules: + - todo: "(TODO|NOTE|FIXME):?"