From d1ca5e5982ec2bae4c36cdca11e4c84ae2afd4fb Mon Sep 17 00:00:00 2001 From: ChaseKnowlden Date: Thu, 3 Feb 2022 13:46:22 -0500 Subject: [PATCH 1/2] Update Lua Grammar --- extensions/lua/cgmanifest.json | 8 +- extensions/lua/syntaxes/lua.tmLanguage.json | 840 ++++++++++++++++---- 2 files changed, 684 insertions(+), 164 deletions(-) diff --git a/extensions/lua/cgmanifest.json b/extensions/lua/cgmanifest.json index 6cefc1ca59e7c..7f2fae0fa8c64 100644 --- a/extensions/lua/cgmanifest.json +++ b/extensions/lua/cgmanifest.json @@ -4,9 +4,9 @@ "component": { "type": "git", "git": { - "name": "textmate/lua.tmbundle", - "repositoryUrl": "https://github.com/textmate/lua.tmbundle", - "commitHash": "8ae5641365b28f697121ba1133890e8d81f5b00e" + "name": "sumneko/lua.tmbundle", + "repositoryUrl": "https://github.com/sumneko/lua.tmbundle", + "commitHash": "e531d0a651f1de222c6059d6e2edaca61b4dd4c4" } }, "licenseDetail": [ @@ -29,4 +29,4 @@ } ], "version": 1 -} \ No newline at end of file +} diff --git a/extensions/lua/syntaxes/lua.tmLanguage.json b/extensions/lua/syntaxes/lua.tmLanguage.json index c2b315705313e..d6d806884608a 100644 --- a/extensions/lua/syntaxes/lua.tmLanguage.json +++ b/extensions/lua/syntaxes/lua.tmLanguage.json @@ -1,146 +1,99 @@ { "information_for_contributors": [ - "This file has been converted from https://github.com/textmate/lua.tmbundle/blob/master/Syntaxes/Lua.plist", + "This file has been converted from https://github.com/sumneko/lua.tmbundle/blob/master/Syntaxes/Lua.plist", "If you want to provide a fix or improvement, please create a pull request against the original repository.", "Once accepted there, we are happy to receive an update request." ], - "version": "https://github.com/textmate/lua.tmbundle/commit/8ae5641365b28f697121ba1133890e8d81f5b00e", + "version": "https://github.com/sumneko/lua.tmbundle/commit/e531d0a651f1de222c6059d6e2edaca61b4dd4c4", "name": "Lua", "scopeName": "source.lua", "patterns": [ { - "begin": "\\b(?:(local)\\s+)?(function)\\s*(?:\\s+([a-zA-Z_][a-zA-Z0-9_]*(?:([\\.:])[a-zA-Z_][a-zA-Z0-9_]*)?)\\s*)?(\\()", + "begin": "\\b(?:(local)\\s+)?(function)\\b(?![,:])", "beginCaptures": { "1": { - "name": "storage.modifier.local.lua" + "name": "keyword.local.lua" }, "2": { "name": "keyword.control.lua" - }, - "3": { - "name": "entity.name.function.lua" - }, - "4": { - "name": "punctuation.separator.parameter.lua" - }, - "5": { - "name": "punctuation.definition.parameters.begin.lua" - } - }, - "end": "\\)", - "endCaptures": { - "0": { - "name": "punctuation.definition.parameters.end.lua" } }, + "end": "(?<=[\\)\\-{}\\[\\]\"'])", "name": "meta.function.lua", "patterns": [ { - "match": "[a-zA-Z_][a-zA-Z0-9_]*", - "name": "variable.parameter.function.lua" + "include": "#comment" }, { - "match": ",", - "name": "punctuation.separator.arguments.lua" + "begin": "(\\()", + "beginCaptures": { + "1": { + "name": "punctuation.definition.parameters.begin.lua" + } + }, + "end": "(\\))|(?=[\\-\\.{}\\[\\]\"'])", + "endCaptures": { + "1": { + "name": "punctuation.definition.parameters.finish.lua" + } + }, + "name": "meta.parameter.lua", + "patterns": [ + { + "include": "#comment" + }, + { + "match": "[a-zA-Z_][a-zA-Z0-9_]*", + "name": "variable.parameter.function.lua" + }, + { + "match": ",", + "name": "punctuation.separator.arguments.lua" + }, + { + "begin": ":", + "beginCaptures": { + "0": { + "name": "punctuation.separator.arguments.lua" + } + }, + "end": "(?=[\\),])", + "patterns": [ + { + "include": "#luadoc.type" + } + ] + } + ] + }, + { + "match": "\\b([a-zA-Z_][a-zA-Z0-9_]*)\\b\\s*(?=:)", + "name": "entity.name.class.lua" + }, + { + "match": "\\b([a-zA-Z_][a-zA-Z0-9_]*)\\b", + "name": "entity.name.function.lua" } ] }, - { - "match": "(?", + "captures": { + "1": { + "name": "string.tag.lua" + } + } + }, + { + "match": "\\<[a-zA-Z_\\*][a-zA-Z0-9_\\.\\*\\-]*\\>", + "name": "storage.type.generic.lua" }, { - "match": "\\b(break|do|else|for|if|elseif|goto|return|then|repeat|while|until|end|function|local|in)\\b", + "match": "\\b(break|do|else|for|if|elseif|goto|return|then|repeat|while|until|end|in)\\b", "name": "keyword.control.lua" }, { - "match": "(?=?|(?=?|(?|\\<", + "name": "keyword.operator.lua" + } + ] + }, + { + "begin": "(?<=---\\s*)@see", + "beginCaptures": { + "0": { + "name": "storage.type.annotation.lua" + } + }, + "end": "(?=\\n)", + "patterns": [ + { + "match": "\\b([a-zA-Z_\\*][a-zA-Z0-9_\\.\\*\\-]*)", + "name": "support.class.lua" + }, + { + "match": "#", + "name": "keyword.operator.lua" + } + ] + }, + { + "begin": "(?<=---\\s*)@diagnostic", + "beginCaptures": { + "0": { + "name": "storage.type.annotation.lua" + } + }, + "end": "(?=\\n)", + "patterns": [ + { + "begin": "([a-zA-Z_\\-0-9]+)[ \\t]*(:)?", + "beginCaptures": { + "1": { + "name": "keyword.other.unit" + }, + "2": { + "name": "keyword.operator.unit" + } + }, + "end": "(?=\\n)", + "patterns": [ + { + "match": "\\b([a-zA-Z_\\*][a-zA-Z0-9_\\-]*)", + "name": "support.class.lua" + }, + { + "match": ",", + "name": "keyword.operator.lua" + } + ] + } + ] + }, + { + "begin": "(?<=---\\s*)@module", + "beginCaptures": { + "0": { + "name": "storage.type.annotation.lua" + } + }, + "end": "(?=\\n)", + "patterns": [ + { + "include": "#string" + } + ] + }, + { + "match": "(?<=---\\s*)@(async|nodiscard)", + "name": "storage.type.annotation.lua" + }, + { + "begin": "(?<=---)\\|\\s*[\\>\\+]?", + "beginCaptures": { + "0": { + "name": "storage.type.annotation.lua" + } + }, + "end": "(?=[\\n#])", + "patterns": [ + { + "include": "#string" + } + ] + } + ] + }, + "luadoc.type": { + "patterns": [ + { + "begin": "\\bfun\\b", + "beginCaptures": { + "0": { + "name": "keyword.control.lua" + } + }, + "end": "(?=\\s)", + "patterns": [ + { + "match": "[\\(\\),:\\?][ \\t]*", + "name": "keyword.operator.lua" + }, + { + "match": "([a-zA-Z_][a-zA-Z0-9_\\.\\*\\[\\]\\<\\>\\,\\-]*)(?", + "name": "storage.type.generic.lua" + }, + { + "match": "\\basync\\b", + "name": "entity.name.tag.lua" + }, + { + "match": "[\\{\\}\\:\\,\\?\\|\\`][ \\t]*", + "name": "keyword.operator.lua" + }, + { + "begin": "(?=[a-zA-Z_\\.\\*\"'\\[])", + "end": "(?=[\\s\\)\\,\\?\\:\\}\\|])", + "patterns": [ + { + "match": "([a-zA-Z0-9_\\.\\*\\[\\]\\<\\>\\,\\-]+)(? Date: Fri, 4 Feb 2022 13:13:42 +0100 Subject: [PATCH 2/2] Update lua-update script and run tests --- extensions/lua/cgmanifest.json | 6 +- extensions/lua/package.json | 2 +- extensions/lua/syntaxes/lua.tmLanguage.json | 2 +- .../test/colorize-results/test_lua.json | 139 +++++++++++++++--- 4 files changed, 124 insertions(+), 25 deletions(-) diff --git a/extensions/lua/cgmanifest.json b/extensions/lua/cgmanifest.json index 7f2fae0fa8c64..2318a09b7378e 100644 --- a/extensions/lua/cgmanifest.json +++ b/extensions/lua/cgmanifest.json @@ -10,7 +10,7 @@ } }, "licenseDetail": [ - "Copyright (c) textmate-lua.tmbundle project authors", + "Copyright (c) sumneko-lua.tmbundle project authors", "", "If not otherwise specified (see below), files in this repository fall under the following license:", "", @@ -25,8 +25,8 @@ "\"tidy\" is accompanied by \"tidy-license.txt\"." ], "license": "TextMate Bundle License", - "version": "0.0.0" + "version": "1.0.0" } ], "version": 1 -} +} \ No newline at end of file diff --git a/extensions/lua/package.json b/extensions/lua/package.json index 8161da9f70516..43e18471bac4d 100644 --- a/extensions/lua/package.json +++ b/extensions/lua/package.json @@ -9,7 +9,7 @@ "vscode": "*" }, "scripts": { - "update-grammar": "node ../node_modules/vscode-grammar-updater/bin textmate/lua.tmbundle Syntaxes/Lua.plist ./syntaxes/lua.tmLanguage.json" + "update-grammar": "node ../node_modules/vscode-grammar-updater/bin sumneko/lua.tmbundle Syntaxes/Lua.plist ./syntaxes/lua.tmLanguage.json" }, "contributes": { "languages": [ diff --git a/extensions/lua/syntaxes/lua.tmLanguage.json b/extensions/lua/syntaxes/lua.tmLanguage.json index d6d806884608a..4ef52fccff23e 100644 --- a/extensions/lua/syntaxes/lua.tmLanguage.json +++ b/extensions/lua/syntaxes/lua.tmLanguage.json @@ -798,4 +798,4 @@ ] } } -} +} \ No newline at end of file diff --git a/extensions/vscode-colorize-tests/test/colorize-results/test_lua.json b/extensions/vscode-colorize-tests/test/colorize-results/test_lua.json index 16117e5a94a73..634986f9090dc 100644 --- a/extensions/vscode-colorize-tests/test/colorize-results/test_lua.json +++ b/extensions/vscode-colorize-tests/test/colorize-results/test_lua.json @@ -89,7 +89,7 @@ }, { "c": "(", - "t": "source.lua meta.function.lua punctuation.definition.parameters.begin.lua", + "t": "source.lua meta.function.lua meta.parameter.lua punctuation.definition.parameters.begin.lua", "r": { "dark_plus": "default: #D4D4D4", "light_plus": "default: #000000", @@ -100,7 +100,7 @@ }, { "c": "n", - "t": "source.lua meta.function.lua variable.parameter.function.lua", + "t": "source.lua meta.function.lua meta.parameter.lua variable.parameter.function.lua", "r": { "dark_plus": "variable: #9CDCFE", "light_plus": "variable: #001080", @@ -111,7 +111,7 @@ }, { "c": ")", - "t": "source.lua meta.function.lua punctuation.definition.parameters.end.lua", + "t": "source.lua meta.function.lua meta.parameter.lua punctuation.definition.parameters.finish.lua", "r": { "dark_plus": "default: #D4D4D4", "light_plus": "default: #000000", @@ -143,7 +143,29 @@ } }, { - "c": " n ", + "c": " ", + "t": "source.lua", + "r": { + "dark_plus": "default: #D4D4D4", + "light_plus": "default: #000000", + "dark_vs": "default: #D4D4D4", + "light_vs": "default: #000000", + "hc_black": "default: #FFFFFF" + } + }, + { + "c": "n", + "t": "source.lua variable.other.lua", + "r": { + "dark_plus": "variable: #9CDCFE", + "light_plus": "variable: #001080", + "dark_vs": "default: #D4D4D4", + "light_vs": "default: #000000", + "hc_black": "variable: #9CDCFE" + } + }, + { + "c": " ", "t": "source.lua", "r": { "dark_plus": "default: #D4D4D4", @@ -177,7 +199,7 @@ }, { "c": "0", - "t": "source.lua constant.numeric.integer.lua", + "t": "source.lua constant.numeric.float.lua", "r": { "dark_plus": "constant.numeric: #B5CEA8", "light_plus": "constant.numeric: #098658", @@ -243,7 +265,7 @@ }, { "c": "1", - "t": "source.lua constant.numeric.integer.lua", + "t": "source.lua constant.numeric.float.lua", "r": { "dark_plus": "constant.numeric: #B5CEA8", "light_plus": "constant.numeric: #098658", @@ -297,7 +319,29 @@ } }, { - "c": " n ", + "c": " ", + "t": "source.lua", + "r": { + "dark_plus": "default: #D4D4D4", + "light_plus": "default: #000000", + "dark_vs": "default: #D4D4D4", + "light_vs": "default: #000000", + "hc_black": "default: #FFFFFF" + } + }, + { + "c": "n", + "t": "source.lua variable.other.lua", + "r": { + "dark_plus": "variable: #9CDCFE", + "light_plus": "variable: #001080", + "dark_vs": "default: #D4D4D4", + "light_vs": "default: #000000", + "hc_black": "variable: #9CDCFE" + } + }, + { + "c": " ", "t": "source.lua", "r": { "dark_plus": "default: #D4D4D4", @@ -331,17 +375,17 @@ }, { "c": "fact", - "t": "source.lua support.function.any-method.lua", + "t": "source.lua entity.name.function.lua", "r": { - "dark_plus": "support.function: #DCDCAA", - "light_plus": "support.function: #795E26", + "dark_plus": "entity.name.function: #DCDCAA", + "light_plus": "entity.name.function: #795E26", "dark_vs": "default: #D4D4D4", "light_vs": "default: #000000", - "hc_black": "support.function: #DCDCAA" + "hc_black": "entity.name.function: #DCDCAA" } }, { - "c": "(n", + "c": "(", "t": "source.lua", "r": { "dark_plus": "default: #D4D4D4", @@ -351,6 +395,17 @@ "hc_black": "default: #FFFFFF" } }, + { + "c": "n", + "t": "source.lua variable.other.lua", + "r": { + "dark_plus": "variable: #9CDCFE", + "light_plus": "variable: #001080", + "dark_vs": "default: #D4D4D4", + "light_vs": "default: #000000", + "hc_black": "variable: #9CDCFE" + } + }, { "c": "-", "t": "source.lua keyword.operator.lua", @@ -364,7 +419,7 @@ }, { "c": "1", - "t": "source.lua constant.numeric.integer.lua", + "t": "source.lua constant.numeric.float.lua", "r": { "dark_plus": "constant.numeric: #B5CEA8", "light_plus": "constant.numeric: #098658", @@ -506,7 +561,29 @@ } }, { - "c": " a ", + "c": " ", + "t": "source.lua", + "r": { + "dark_plus": "default: #D4D4D4", + "light_plus": "default: #000000", + "dark_vs": "default: #D4D4D4", + "light_vs": "default: #000000", + "hc_black": "default: #FFFFFF" + } + }, + { + "c": "a", + "t": "source.lua variable.other.lua", + "r": { + "dark_plus": "variable: #9CDCFE", + "light_plus": "variable: #001080", + "dark_vs": "default: #D4D4D4", + "light_vs": "default: #000000", + "hc_black": "variable: #9CDCFE" + } + }, + { + "c": " ", "t": "source.lua", "r": { "dark_plus": "default: #D4D4D4", @@ -661,17 +738,39 @@ }, { "c": "fact", - "t": "source.lua support.function.any-method.lua", + "t": "source.lua entity.name.function.lua", "r": { - "dark_plus": "support.function: #DCDCAA", - "light_plus": "support.function: #795E26", + "dark_plus": "entity.name.function: #DCDCAA", + "light_plus": "entity.name.function: #795E26", "dark_vs": "default: #D4D4D4", "light_vs": "default: #000000", - "hc_black": "support.function: #DCDCAA" + "hc_black": "entity.name.function: #DCDCAA" + } + }, + { + "c": "(", + "t": "source.lua", + "r": { + "dark_plus": "default: #D4D4D4", + "light_plus": "default: #000000", + "dark_vs": "default: #D4D4D4", + "light_vs": "default: #000000", + "hc_black": "default: #FFFFFF" + } + }, + { + "c": "a", + "t": "source.lua variable.other.lua", + "r": { + "dark_plus": "variable: #9CDCFE", + "light_plus": "variable: #001080", + "dark_vs": "default: #D4D4D4", + "light_vs": "default: #000000", + "hc_black": "variable: #9CDCFE" } }, { - "c": "(a))", + "c": "))", "t": "source.lua", "r": { "dark_plus": "default: #D4D4D4", @@ -681,4 +780,4 @@ "hc_black": "default: #FFFFFF" } } -] +] \ No newline at end of file