From 4be3e9122c390bef91dffb9fc6ceb98b0c5cace3 Mon Sep 17 00:00:00 2001 From: supbish Date: Sat, 18 Aug 2018 07:00:51 -0400 Subject: [PATCH] Lua syntax improvements; fixes #1155, fixes #1136 --- runtime/syntax/lua.yaml | 62 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 58 insertions(+), 4 deletions(-) diff --git a/runtime/syntax/lua.yaml b/runtime/syntax/lua.yaml index cb1ee24e..e5dab4ef 100644 --- a/runtime/syntax/lua.yaml +++ b/runtime/syntax/lua.yaml @@ -23,7 +23,8 @@ rules: - constant: "\\b(false|nil|true)\\b" - statement: "(\\b(dofile|require|include)|%q|%!|%Q|%r|%x)\\b" - constant.number: "\\b([0-9]+)\\b" - - symbol: "(\\(|\\)|\\[|\\]|\\{|\\}|\\*\\*|\\*|/|%|\\+|-|\\^|>|>=|<|<=|~=|=|[\\.]{2,3}|#)" + - symbol.brackets: "[(){}\\[\\]]" + - symbol: "(\\*|//|/|%|\\+|-|\\^|>|>=|<|<=|~=|=|[\\.]{2,3}|#)" - constant.string: start: "\"" @@ -45,11 +46,64 @@ 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.block: - start: "\\-\\-\\[(\\=*|\\#*)\\[" - end: "\\-\\-\\](\\=*|\\#*)\\]" + 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):?" @@ -59,4 +113,4 @@ rules: start: "\\-\\-" end: "$" rules: - - todo: "(TODO|NOTE|FIXME):?" + - todo: "(TODO|NOTE|FIXME):?"