diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 46e2c822..96367120 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -22,6 +22,8 @@ 'beginCaptures': '1': 'name': 'keyword.control.js' + 'end': '(?=;|$)' + 'name': 'meta.import.js' 'patterns': [ { 'comment': '{ member1 , member2 as alias2 , [...] }' @@ -70,6 +72,11 @@ } { 'comment': '(default|*|name) as alias' + 'match': '''(?x) + (?: \\b(default)\\b | (\\*) | \\b([a-zA-Z_$][a-zA-Z_$0-9]*)\\b) + \\s*\\b(as)\\b\\s* + (?: (\\b default \\b | \\*) | \\b([a-zA-Z_$][a-zA-Z_$0-9]*)\\b) + ''' 'captures': '1': 'name': 'variable.language.default.js' @@ -83,13 +90,6 @@ 'name': 'invalid.illegal.js' '6': 'name': 'variable.other.module-alias.js' - 'match': '(?x) - (?: \\b(default)\\b | (\\*) | \\b([a-zA-Z_$][a-zA-Z_$0-9]*)\\b) - \\s* - (\\b as \\b) - \\s* - (?: (\\b default \\b | \\*) | \\b([a-zA-Z_$][a-zA-Z_$0-9]*)\\b) - ' } { 'match': '\\*' @@ -118,8 +118,6 @@ 'name': 'meta.delimiter.object.comma.js' } ] - 'end': '(?=;|$)' - 'name': 'meta.import.js' } { 'comment': 'ES6 export: `export default (variable|class|function, etc.)`' @@ -140,6 +138,8 @@ 'beginCaptures': '1': 'name': 'keyword.control.js' + 'end': '(?=;|\\bfunction\\b|\\bclass\\b|\\blet\\b|\\bvar\\b|\\bconst\\b|$)' + 'name': 'meta.export.js' 'patterns': [ { 'include': '#numbers' @@ -157,6 +157,11 @@ 'patterns': [ { 'comment': '(default|name) as alias' + 'match': '''(?x) + (?: \\b(default)\\b | \\b([a-zA-Z_$][a-zA-Z_$0-9]*)\\b) + \\s*\\b(as)\\b\\s* + (?: \\b(default)\\b | (\\*) | \\b([a-zA-Z_$][a-zA-Z_$0-9]*)\\b) + ''' 'captures': '1': 'name': 'variable.language.default.js' @@ -170,13 +175,6 @@ 'name': 'invalid.illegal.js' '6': 'name': 'variable.other.module-alias.js' - 'match': '(?x) - (?: \\b(default)\\b | \\b([a-zA-Z_$][a-zA-Z_$0-9]*)\\b) - \\s* - (\\b as \\b) - \\s* - (?: \\b(default)\\b | (\\*) | \\b([a-zA-Z_$][a-zA-Z_$0-9]*)\\b) - ' } { 'match': ',' @@ -204,6 +202,11 @@ 'patterns': [ { 'comment': 'name as (default|alias)' + 'match': '''(?x) + (?: \\b(default)\\b | \\b([a-zA-Z_$][a-zA-Z_$0-9]*)\\b) + \\s*\\b(as)\\b\\s* + (?: \\b(default)\\b | (\\*) | \\b([a-zA-Z_$][a-zA-Z_$0-9]*)\\b) + ''' 'captures': '1': 'name': 'invalid.illegal.js' @@ -217,13 +220,6 @@ 'name': 'invalid.illegal.js' '6': 'name': 'variable.other.module-alias.js' - 'match': '(?x) - (?: \\b(default)\\b | \\b([a-zA-Z_$][a-zA-Z_$0-9]*)\\b) - \\s* - (\\b as \\b) - \\s* - (?: \\b(default)\\b | (\\*) | \\b([a-zA-Z_$][a-zA-Z_$0-9]*)\\b) - ' } { 'include': '#comments' @@ -268,8 +264,6 @@ 'include': '#operators' } ] - 'end': '(?=;|\\bfunction\\b|\\bclass\\b|\\blet\\b|\\bvar\\b|\\bconst\\b|$)' - 'name': 'meta.export.js' } { 'match': '(? { … }' - 'name': 'meta.function.arrow.js' 'begin': '([a-zA-Z_?$][\\w?$]*)\\s*(=)\\s*(\\()(?=(?:[^\\(\\)]*)?\\)\\s*=>)' 'beginCaptures': '1': @@ -575,6 +568,7 @@ 'name': 'punctuation.definition.parameters.end.js' '2': 'name': 'storage.type.arrow.js' + 'name': 'meta.function.arrow.js' 'patterns': [ { 'include': '#function-params' @@ -583,7 +577,6 @@ } { 'comment': 'match stuff like: Sound.play = (a,b) => { … }' - 'name': 'meta.function.arrow.js' 'begin': '([a-zA-Z_?$]*)\\.([a-zA-Z_?$][\\w?$]*)\\s*(=)\\s*(\\()(?=(?:[^\\(\\)]*)?\\)\\s*=>)' 'beginCaptures': '1': @@ -600,6 +593,7 @@ 'name': 'punctuation.definition.parameters.end.js' '2': 'name': 'storage.type.arrow.js' + 'name': 'meta.function.arrow.js' 'patterns': [ { 'include': '#function-params' @@ -607,12 +601,12 @@ ] } { + 'match': '(new)\\s+(\\$?\\w+(?:\\.\\w*)?)' 'captures': '1': 'name': 'keyword.operator.new.js' '2': 'name': 'entity.name.type.instance.js' - 'match': '(new)\\s+(\\$?\\w+(?:\\.\\w*)?)' 'name': 'meta.class.instance.constructor' } { @@ -640,12 +634,12 @@ 'include': '#comments' } { + 'match': '()' 'captures': '0': 'name': 'punctuation.definition.comment.html.js' '2': 'name': 'punctuation.definition.comment.html.js' - 'match': '()' 'name': 'comment.block.html.js' } { @@ -871,13 +865,13 @@ 'name': 'meta.delimiter.method.period.js' } { + 'comment': 'Allows the special return snippet to fire.' + 'match': '({)(})' 'captures': '1': 'name': 'punctuation.section.scope.begin.js' '2': 'name': 'punctuation.section.scope.end.js' - 'comment': 'Allows the special return snippet to fire.' - 'match': '({)(})' } { 'match': '{|}' @@ -1015,7 +1009,6 @@ 'methods': 'patterns': [ { - 'name': 'meta.method.js' 'comment': 'match regular function like: function myFunc(arg) { … }' 'begin': '\\b((?!(?:break|case|catch|continue|do|else|finally|for|function|if|export|import|package|return|switch|throw|try|while|with)[\\s\\(])(?:[a-zA-Z_$][a-zA-Z_$0-9]*))\\s*(\\()(?=(?:[^\\(\\)]*)?\\)\\s*\\{)' 'beginCaptures': @@ -1027,6 +1020,7 @@ 'endCaptures': '1': 'name': 'punctuation.definition.parameters.end.js' + 'name': 'meta.method.js' 'patterns': [ { 'include': '#function-params' @@ -1200,13 +1194,13 @@ 'captures': '0': 'name': 'punctuation.definition.comment.js' + 'end': '\\*/' + 'name': 'comment.block.documentation.js' 'patterns': [ { 'include': '#docblock' } ] - 'end': '\\*/' - 'name': 'comment.block.documentation.js' } { 'begin': '/\\*' diff --git a/grammars/regular expressions (javascript).cson b/grammars/regular expressions (javascript).cson index 213b8363..01e6d507 100644 --- a/grammars/regular expressions (javascript).cson +++ b/grammars/regular expressions (javascript).cson @@ -94,6 +94,7 @@ 'name': 'constant.other.character-class.set.regexp' 'patterns': [ { + 'match': '(?:.|(\\\\(?:[0-7]{3}|x\\h\\h|u\\h\\h\\h\\h))|(\\\\c[A-Z])|(\\\\.))\\-(?:[^\\]\\\\]|(\\\\(?:[0-7]{3}|x\\h\\h|u\\h\\h\\h\\h))|(\\\\c[A-Z])|(\\\\.))' 'captures': '1': 'name': 'constant.character.numeric.regexp' @@ -107,7 +108,6 @@ 'name': 'constant.character.control.regexp' '6': 'name': 'constant.character.escape.backslash.regexp' - 'match': '(?:.|(\\\\(?:[0-7]{3}|x\\h\\h|u\\h\\h\\h\\h))|(\\\\c[A-Z])|(\\\\.))\\-(?:[^\\]\\\\]|(\\\\(?:[0-7]{3}|x\\h\\h|u\\h\\h\\h\\h))|(\\\\c[A-Z])|(\\\\.))' 'name': 'constant.other.character-class.range.regexp' } {