From 9a7e29a46a47f573edf57baf8240d76582126080 Mon Sep 17 00:00:00 2001 From: jwortmann Date: Tue, 31 May 2022 11:07:50 +0200 Subject: [PATCH 01/22] [JavaScript] Standardize null-coalescing operator scope (#3411) [JavaScript] Standardize null-coalescing operator scope (#3411) This commit adjusts the scope for nullish coalescing operator to `keyword.operator.null-coalescing`. It is already used in the PHP. It is defined as a kind of logical operator at MDN Web docs, but this commit follows the scheme of ternary operators, as both return values instead of logical results. --- JavaScript/JavaScript.sublime-syntax | 5 ++++- JavaScript/tests/syntax_test_js.js | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/JavaScript/JavaScript.sublime-syntax b/JavaScript/JavaScript.sublime-syntax index 1bb91c5ad53..1a46b9053cb 100644 --- a/JavaScript/JavaScript.sublime-syntax +++ b/JavaScript/JavaScript.sublime-syntax @@ -1263,9 +1263,12 @@ contexts: \?\?= scope: keyword.operator.assignment.augmented.js push: expression-begin - - match: '&&|\|\||\?\?' + - match: '&&|\|\|' scope: keyword.operator.logical.js push: expression-begin + - match: \?\? + scope: keyword.operator.null-coalescing.js + push: expression-begin - match: |- (?x) << | # bitwise-shift left-to-right both diff --git a/JavaScript/tests/syntax_test_js.js b/JavaScript/tests/syntax_test_js.js index be6ec601058..ae270c85c7a 100644 --- a/JavaScript/tests/syntax_test_js.js +++ b/JavaScript/tests/syntax_test_js.js @@ -1612,7 +1612,7 @@ debugger // <- meta.sequence a ?? b; -// ^^ keyword.operator.logical +// ^^ keyword.operator.null-coalescing a &&= b; // ^^^ keyword.operator.assignment.augmented From a8ded3ac17bfbed8dead032e18e3765610c365f8 Mon Sep 17 00:00:00 2001 From: jwortmann Date: Tue, 31 May 2022 11:10:21 +0200 Subject: [PATCH 02/22] [C#] Standardize some operator scope names (#3412) This commit... 1. adjusts the scope for nullish coalescing operator to `keyword.operator.null-coalescing`. It is already used in the PHP. It is defined as a kind of logical operator at MDN Web docs, but this commit follows the scheme of ternary operators, as both return values instead of logical results. 2. assigns `keyword.operator.assignment.augmented` to augmented assignments, as already used in various other syntaxes. --- C#/C#.sublime-syntax | 4 +++- C#/tests/syntax_test_C#8.cs | 2 +- C#/tests/syntax_test_C#9.cs | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/C#/C#.sublime-syntax b/C#/C#.sublime-syntax index 501e64158ce..9b216811f67 100644 --- a/C#/C#.sublime-syntax +++ b/C#/C#.sublime-syntax @@ -1276,7 +1276,9 @@ contexts: - match: '->' scope: punctuation.accessor.arrow.cs - match: '{{bin_op}}=' - scope: keyword.operator.cs + scope: keyword.operator.assignment.augmented.cs + - match: \?\? + scope: keyword.operator.null-coalescing.cs - match: '{{bin_op}}|{{unary_op}}' scope: keyword.operator.cs - match: '=' diff --git a/C#/tests/syntax_test_C#8.cs b/C#/tests/syntax_test_C#8.cs index 28be2f22d88..5ccfe94a465 100644 --- a/C#/tests/syntax_test_C#8.cs +++ b/C#/tests/syntax_test_C#8.cs @@ -7,7 +7,7 @@ int? i = null; numbers ??= new List(); -/// ^^^ keyword.operator +/// ^^^ keyword.operator.assignment.augmented numbers.Add(i ??= 17); numbers.Add(i ??= 20); diff --git a/C#/tests/syntax_test_C#9.cs b/C#/tests/syntax_test_C#9.cs index 2fa8969f71e..479ee4f05d1 100644 --- a/C#/tests/syntax_test_C#9.cs +++ b/C#/tests/syntax_test_C#9.cs @@ -21,6 +21,7 @@ public string LastName /// ^^^^ keyword.declaration.function.accessor.set /// ^^ keyword.declaration.function.arrow /// ^^^^^^^^ variable.other +/// ^^ keyword.operator.null-coalescing } } From 12ba444ac84465589d44f88204c679c6ab01cea6 Mon Sep 17 00:00:00 2001 From: jwortmann Date: Tue, 31 May 2022 11:14:40 +0200 Subject: [PATCH 03/22] [Python] Standardize scope name for throwaway variables (#3413) This commit assigns `variable.language.anonymous` to throwaway variables which enables highlighting `_` special. The scope is already used in Erlang, Haskell, Matlab & Java. See also: https://github.com/SublimeText/ScopeNamingGuidelines/issues/5 --- Python/Python.sublime-syntax | 4 ++-- Python/syntax_test_python.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Python/Python.sublime-syntax b/Python/Python.sublime-syntax index f90c06dcdcd..b9a33053711 100644 --- a/Python/Python.sublime-syntax +++ b/Python/Python.sublime-syntax @@ -1766,11 +1766,11 @@ contexts: wildcard-variables: - match: _(?!{{identifier_continue}}) - scope: variable.language.python + scope: variable.language.anonymous.python wildcard-variable: - match: _(?!{{identifier_continue}}) - scope: variable.language.python + scope: variable.language.anonymous.python pop: true line-continuation: diff --git a/Python/syntax_test_python.py b/Python/syntax_test_python.py index 5ff3a2bb256..49f17346253 100644 --- a/Python/syntax_test_python.py +++ b/Python/syntax_test_python.py @@ -353,7 +353,7 @@ # ^^^ variable.other.constant _ self -# <- variable.language.python +# <- variable.language.anonymous.python # ^^^^ variable.language.python @@ -1001,7 +1001,7 @@ def _(): # ^^ meta.statement.conditional.case.patterns.python # ^ meta.statement.conditional.case.python # ^^^^ keyword.control.conditional.case.python -# ^ variable.language.python +# ^ variable.language.anonymous.python # ^ punctuation.section.block.conditional.case.python # ^^^^^^^^^^ comment.line.number-sign.python print("Code not found") @@ -1280,7 +1280,7 @@ def _(): case *expr as _: # ^^ keyword.control.conditional.case.as.python -# ^ variable.language.python +# ^ variable.language.anonymous.python case *expr as isinstance: # ^^ keyword.control.conditional.case.as.python From e73a3e9d4d3e4a30c3bb3deba4ad065e9ca3f0bc Mon Sep 17 00:00:00 2001 From: jwortmann Date: Tue, 31 May 2022 11:16:05 +0200 Subject: [PATCH 04/22] [Go] Standardize scope name for throwaway variables (#3414) This commit assigns `variable.language.anonymous` to throwaway variables which enables highlighting `_` special. The scope is already used in Erlang, Haskell, Java, Matlab & Python. See also: https://github.com/SublimeText/ScopeNamingGuidelines/issues/5 --- Go/Go.sublime-syntax | 38 +++++++++++++++++++------------------- Go/syntax_test_go.go | 14 +++++++------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/Go/Go.sublime-syntax b/Go/Go.sublime-syntax index cbd3f4a0a8b..ae61a6e5581 100644 --- a/Go/Go.sublime-syntax +++ b/Go/Go.sublime-syntax @@ -252,7 +252,7 @@ contexts: - include: match-call-or-type-conversion - include: match-short-variable-declarations - match: \b_\b - scope: variable.language.blank.go + scope: variable.language.anonymous.go - match: '{{ident}}' scope: variable.other.go @@ -327,7 +327,7 @@ contexts: push: - include: match-comments - match: \b_\b - scope: variable.language.blank.go + scope: variable.language.anonymous.go - match: '{{ident}}' scope: variable.other.readwrite.declaration.go - include: match-comma @@ -427,7 +427,7 @@ contexts: - match: '{{ident}}(?={{noise}}\.)' scope: variable.other.go - match: \b_\b - scope: variable.language.blank.go + scope: variable.language.anonymous.go pop: true - include: pop-type-identifier - include: pop-before-nonblank @@ -663,12 +663,12 @@ contexts: pop: true - match: \b_\b(?={{noise}},) - scope: variable.language.blank.go + scope: variable.language.anonymous.go - match: '{{ident}}(?={{noise}},)' scope: variable.other.constant.declaration.go - match: \b_\b - scope: variable.language.blank.go + scope: variable.language.anonymous.go push: pop-const-type-and-or-assignment - match: '{{ident}}' scope: variable.other.constant.declaration.go @@ -680,12 +680,12 @@ contexts: - include: match-comma - match: \b_\b(?={{noise}},) - scope: variable.language.blank.go + scope: variable.language.anonymous.go - match: '{{ident}}(?={{noise}},)' scope: variable.other.constant.declaration.go - match: \b_\b - scope: variable.language.blank.go + scope: variable.language.anonymous.go set: pop-const-type-and-or-assignment - match: '{{ident}}' scope: variable.other.constant.declaration.go @@ -809,7 +809,7 @@ contexts: scope: punctuation.section.parens.end.go pop: true - match: \b_\b - scope: variable.language.blank.go + scope: variable.language.anonymous.go push: - match: (?=\)) pop: true @@ -823,7 +823,7 @@ contexts: - include: match-any - match: \b_\b - scope: variable.language.blank.go + scope: variable.language.anonymous.go set: pop-type-alias-or-typedef - match: '{{ident}}' scope: entity.name.type.go @@ -843,12 +843,12 @@ contexts: pop: true - match: \b_\b(?={{noise}},) - scope: variable.language.blank.go + scope: variable.language.anonymous.go - match: '{{ident}}(?={{noise}},)' scope: variable.other.readwrite.declaration.go - match: \b_\b - scope: variable.language.blank.go + scope: variable.language.anonymous.go push: pop-var-type-and-or-assignment - match: '{{ident}}' scope: variable.other.readwrite.declaration.go @@ -860,12 +860,12 @@ contexts: - include: match-comma - match: \b_\b(?={{noise}},) - scope: variable.language.blank.go + scope: variable.language.anonymous.go - match: '{{ident}}(?={{noise}},)' scope: variable.other.readwrite.declaration.go - match: \b_\b - scope: variable.language.blank.go + scope: variable.language.anonymous.go set: pop-var-type-and-or-assignment - match: '{{ident}}' scope: variable.other.readwrite.declaration.go @@ -876,7 +876,7 @@ contexts: pop-func-signature: - include: match-comments - match: \b_\b - scope: variable.language.blank.go + scope: variable.language.anonymous.go set: pop-func-parameter-and-return-lists - match: '{{ident}}' scope: entity.name.function.go @@ -954,7 +954,7 @@ contexts: - include: match-comma - include: match-ellipsis - match: \b_\b - scope: variable.language.blank.go + scope: variable.language.anonymous.go push: pop-parameter-type - match: '{{ident}}' scope: variable.parameter.go @@ -1063,7 +1063,7 @@ contexts: scope: entity.other.inherited-class.go - match: \b_\b - scope: variable.language.blank.go + scope: variable.language.anonymous.go - match: '{{ident}}' scope: variable.other.member.declaration.go push: @@ -1147,14 +1147,14 @@ contexts: pop-named-type: - include: match-comments - match: \b_\b - scope: variable.language.blank.go + scope: variable.language.anonymous.go pop: true - match: '{{ident}}(?={{noise}}\.)' scope: variable.other.go - match: \. scope: punctuation.accessor.dot.go - match: \b_\b - scope: variable.language.blank.go + scope: variable.language.anonymous.go pop: true - include: pop-type-identifier - include: pop-before-nonblank @@ -1248,7 +1248,7 @@ contexts: pop-member: - match: \b_\b - scope: variable.language.blank.go + scope: variable.language.anonymous.go pop: true - match: '{{ident}}' scope: variable.other.member.go diff --git a/Go/syntax_test_go.go b/Go/syntax_test_go.go index 2f7e95c4667..cf3403bb0fe 100644 --- a/Go/syntax_test_go.go +++ b/Go/syntax_test_go.go @@ -232,7 +232,7 @@ Note: built-ins are tested separately. Search for "# Built-in Types". chan _ // ^^^^ keyword.declaration.chan.go -// ^ variable.language.blank.go +// ^ variable.language.anonymous.go chan typ // ^^^^ keyword.declaration.chan.go @@ -1385,7 +1385,7 @@ Note: built-ins are tested separately. Search for "# Built-in Types". type _ typ // ^^^^ keyword.declaration.type.go -// ^ variable.language.blank.go +// ^ variable.language.anonymous.go // ^^^ storage.type.go type Type typ @@ -1556,7 +1556,7 @@ Note: built-ins are tested separately. Search for "# Built-in Types". const _ = 10 // ^^^^^ keyword.declaration.const.go -// ^ variable.language.blank.go +// ^ variable.language.anonymous.go // ^ keyword.operator.assignment.go // ^^ meta.number.integer.decimal.go constant.numeric.value.go @@ -1748,14 +1748,14 @@ Note: built-ins are tested separately. Search for "# Built-in Types". // ^ meta.number.integer.decimal.go constant.numeric.value.go var _ = iota // ^^^ keyword.declaration.var.go -// ^ variable.language.blank.go +// ^ variable.language.anonymous.go // ^ keyword.operator.assignment.go // ^^^^ variable.other.go -constant } var _ = log.Println // ^^^ keyword.declaration.var.go -// ^ variable.language.blank.go +// ^ variable.language.anonymous.go // ^ keyword.operator.assignment.go // ^^^ variable.other.go // ^ punctuation.accessor.dot.go @@ -2907,12 +2907,12 @@ every type individually. type _ typ // ^^^^ keyword.declaration.type.go -// ^ variable.language.blank.go +// ^ variable.language.anonymous.go // ^^^ storage.type.go -support type _ int // ^^^^ keyword.declaration.type.go -// ^ variable.language.blank.go +// ^ variable.language.anonymous.go // ^^^ storage.type.go support.type.builtin.go const ident typ From 83a8f3e886b56c5c87957adb5c5f2ab61833f3b0 Mon Sep 17 00:00:00 2001 From: jwortmann Date: Tue, 31 May 2022 11:17:21 +0200 Subject: [PATCH 05/22] [C#] Standardize scope name for throwaway variables (#3415) This commit assigns `variable.language.anonymous` to throwaway variables which enables highlighting `_` special. The scope is already used in Erlang, Go, Haskell, Java, Matlab & Python. See also: https://github.com/SublimeText/ScopeNamingGuidelines/issues/5 --- C#/C#.sublime-syntax | 8 ++++---- C#/tests/syntax_test_C#7.cs | 4 ++-- C#/tests/syntax_test_C#8.cs | 8 ++++---- C#/tests/syntax_test_C#9.cs | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/C#/C#.sublime-syntax b/C#/C#.sublime-syntax index 9b216811f67..e1d970642a2 100644 --- a/C#/C#.sublime-syntax +++ b/C#/C#.sublime-syntax @@ -1424,7 +1424,7 @@ contexts: - match: ':' scope: keyword.operator.assignment.cs - match: _\b - scope: variable.language.deconstruction.discard.cs + scope: variable.language.anonymous.cs - match: (?!{{reserved}})(?={{namespaced_name}}{{type_suffix}}\s+{{name}}\s*[:,]) push: var_declaration_explicit - match: '({{name}})(<)' @@ -2075,7 +2075,7 @@ contexts: pop: true - include: line_of_code_in - match: \b_\b - scope: variable.language.deconstruction.discard.cs + scope: variable.language.anonymous.cs - match: '\bwhen\b' scope: keyword.control.switch.case.when.cs - match: \( @@ -2088,7 +2088,7 @@ contexts: - match: ',' scope: punctuation.separator.sequence.cs - match: _\b - scope: variable.language.deconstruction.discard.cs + scope: variable.language.anonymous.cs - include: line_of_code_in_no_semicolon # needed for "when" syntax? - match: (?={{namespaced_name}}\s+(?:\{|(?!{{reserved}}|when\b){{name}})) push: [maybe_pattern_matching_object, var_declaration] @@ -2153,7 +2153,7 @@ contexts: scope: meta.sequence.tuple.cs punctuation.section.sequence.end.cs pop: true - match: _\b - scope: variable.language.deconstruction.discard.cs + scope: variable.language.anonymous.cs - match: '{{name}}' scope: variable.other.cs - match: ',' diff --git a/C#/tests/syntax_test_C#7.cs b/C#/tests/syntax_test_C#7.cs index 59078ec6fa2..2b155204284 100644 --- a/C#/tests/syntax_test_C#7.cs +++ b/C#/tests/syntax_test_C#7.cs @@ -424,7 +424,7 @@ string Beta /// ^^^^^^ storage.type /// ^^^^ variable.other /// ^ punctuation.separator.sequence -/// ^ variable.language.deconstruction.discard +/// ^ variable.language.anonymous /// ^ punctuation.separator.sequence /// ^^^^^^ storage.type /// ^^^^ variable.other @@ -436,7 +436,7 @@ string Beta /// ^ punctuation.separator.sequence /// ^^^^^^^^^^ variable.other /// ^ punctuation.separator.sequence -/// ^ variable.language.deconstruction +/// ^ variable.language.anonymous /// ^ punctuation.section.sequence.end /// ^ keyword.operator.assignment var (_, _, _, pop1, _, pop2) = QueryCityDataForYears("New York City", 1960, 2010); diff --git a/C#/tests/syntax_test_C#8.cs b/C#/tests/syntax_test_C#8.cs index 5ccfe94a465..5b52894cdef 100644 --- a/C#/tests/syntax_test_C#8.cs +++ b/C#/tests/syntax_test_C#8.cs @@ -48,7 +48,7 @@ public static decimal CalculateToll(object vehicle) => /// ^^ meta.method meta.block punctuation.separator.case-expression _ => throw new ArgumentException("Not a known vehicle type", nameof(vehicle)) -/// ^ variable.language.deconstruction.discard +/// ^ variable.language.anonymous /// ^^ punctuation.separator.case-expression }; @@ -239,11 +239,11 @@ public static string RockPaperScissors(string first, string second) var (_, _) => Quadrant.OnBorder, /// ^^^ storage.type.variable /// ^^^^^^ meta.sequence.tuple -/// ^ variable.language.deconstruction.discard +/// ^ variable.language.anonymous /// ^ punctuation.separator.sequence -/// ^ variable.language.deconstruction.discard +/// ^ variable.language.anonymous _ => Quadrant.Unknown -/// ^ variable.language.deconstruction.discard +/// ^ variable.language.anonymous /// ^^ punctuation.separator.case-expression }; /// <- punctuation.section.block.end diff --git a/C#/tests/syntax_test_C#9.cs b/C#/tests/syntax_test_C#9.cs index 479ee4f05d1..595335fc610 100644 --- a/C#/tests/syntax_test_C#9.cs +++ b/C#/tests/syntax_test_C#9.cs @@ -92,7 +92,7 @@ public record Student : Person { int ID; } /// ^^ constant.numeric.value /// ^^ punctuation.separator.case-expression _ => "More than 10" -/// ^ variable.language.deconstruction.discard +/// ^ variable.language.anonymous /// ^^ punctuation.separator.case-expression } + "."; /// <- punctuation.section.block.end @@ -138,7 +138,7 @@ static bool CheckIfCanWalkIntoBank(Bank bank, bool isVip) /// ^ punctuation.accessor.dot /// ^^^^ variable.other /// ^ punctuation.separator.sequence -/// ^ variable.language.deconstruction.discard +/// ^ variable.language.anonymous /// ^ punctuation.section.sequence.end /// ^^ punctuation.separator.case-expression /// ^^^^ constant.language From ee0146e562094e3fd0a73722ca40fe21ff7b2007 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Tue, 31 May 2022 12:49:35 +0200 Subject: [PATCH 06/22] [Perl] Unify namespace scopes (#3352) This commit... 1. scopes `CORE::` support.namespace as it is a builtin namespace to explicitly address core functionality 2. scopes qualifiers in `package` and `require` statements `variable.namespace` --- Perl/Perl.sublime-syntax | 29 +++++++++-------- Perl/syntax_test_perl.pl | 67 ++++++++++++++++++++++------------------ 2 files changed, 53 insertions(+), 43 deletions(-) diff --git a/Perl/Perl.sublime-syntax b/Perl/Perl.sublime-syntax index 6ad29675b84..954cdeba3a4 100644 --- a/Perl/Perl.sublime-syntax +++ b/Perl/Perl.sublime-syntax @@ -411,16 +411,18 @@ contexts: qualified-namespace: - match: ({{identifier}})?(::) captures: - 1: entity.name.namespace.perl + 1: variable.namespace.perl 2: punctuation.accessor.double-colon.perl - set: - - meta_scope: meta.path.perl - - match: ({{identifier}})(::) - captures: - 1: entity.name.namespace.perl - 2: punctuation.accessor.double-colon.perl - - include: unqualified-namespace - - include: immediately-pop + set: qualified-namespace-content + + qualified-namespace-content: + - meta_scope: meta.path.perl + - match: ({{identifier}})(::) + captures: + 1: variable.namespace.perl + 2: punctuation.accessor.double-colon.perl + - include: unqualified-namespace + - include: immediately-pop unqualified-namespace: - match: '{{identifier}}' @@ -1066,7 +1068,7 @@ contexts: # The `meta.path` is not applied for simplicity reasons. - match: \b(CORE)(::)(?={{reserved_words}}) captures: - 1: variable.namespace.perl + 1: support.namespace.perl 2: punctuation.accessor.double-colon.perl # declaration - match: \b(?:{{storage_keywords}}){{break}} @@ -1797,11 +1799,12 @@ contexts: ###[ VARIABLES ]############################################################## qualified-variables: - - match: ([$@%*]#?)({{identifier}})?(::) + - match: ([$@%*]#?)(?:(CORE)|({{identifier}}))?(::) captures: 1: punctuation.definition.variable.perl - 2: variable.namespace.perl - 3: punctuation.accessor.double-colon.perl + 2: support.namespace.perl + 3: variable.namespace.perl + 4: punctuation.accessor.double-colon.perl push: [maybe-item-access, qualified-variables-path] qualified-variables-path: diff --git a/Perl/syntax_test_perl.pl b/Perl/syntax_test_perl.pl index e8c68e09549..ba96ed7b8b3 100644 --- a/Perl/syntax_test_perl.pl +++ b/Perl/syntax_test_perl.pl @@ -206,7 +206,7 @@ =head1 B<--param> # <- meta.format.perl punctuation.terminator.format.perl CORE::format if::format = -#^^^ variable.namespace.perl - meta.format +#^^^ support.namespace.perl - meta.format # ^^^^^^^^^^^^^^^^^^^^ meta.format.perl # ^^ punctuation.accessor.double-colon.perl # ^^^^^^ storage.type.format.perl @@ -1718,25 +1718,25 @@ =head1 B<--param> # ^ punctuation.terminator.statement.perl CORE::q// -# ^^^^ variable.namespace.perl +# ^^^^ support.namespace.perl # ^^ punctuation.accessor.double-colon.perl # ^ support.function.perl # ^ punctuation.section.generic.begin.perl # ^ punctuation.section.generic.end.perl CORE::qq// -# ^^^^ variable.namespace.perl +# ^^^^ support.namespace.perl # ^^ punctuation.accessor.double-colon.perl # ^^ support.function.perl # ^ punctuation.section.generic.begin.perl # ^ punctuation.section.generic.end.perl CORE::qx// -# ^^^^ variable.namespace.perl +# ^^^^ support.namespace.perl # ^^ punctuation.accessor.double-colon.perl # ^^ support.function.perl # ^ punctuation.section.generic.begin.perl # ^ punctuation.section.generic.end.perl CORE::qw// -# ^^^^ variable.namespace.perl +# ^^^^ support.namespace.perl # ^^ punctuation.accessor.double-colon.perl # ^^ support.function.perl # ^ punctuation.section.generic.begin.perl @@ -1830,11 +1830,11 @@ =head1 B<--param> # ^ punctuation.terminator.statement.perl # ^ comment.line.number-sign.perl punctuation.definition.comment.perl CORE::m -# ^^^^ variable.namespace.perl +# ^^^^ support.namespace.perl # ^^ punctuation.accessor.double-colon.perl # ^ support.function.perl CORE::m//g -# ^^^^ variable.namespace.perl +# ^^^^ support.namespace.perl # ^^ punctuation.accessor.double-colon.perl # ^ support.function.perl # ^ punctuation.section.generic.begin.perl @@ -2026,11 +2026,11 @@ =head1 B<--param> # ^ constant.language.flags.regexp.perl # ^ punctuation.terminator.statement.perl CORE::s -# ^^^^ variable.namespace.perl +# ^^^^ support.namespace.perl # ^^ punctuation.accessor.double-colon.perl # ^ support.function.perl CORE::s///g -# ^^^^ variable.namespace.perl +# ^^^^ support.namespace.perl # ^^ punctuation.accessor.double-colon.perl # ^ support.function.perl # ^ punctuation.section.generic.begin.perl @@ -2062,11 +2062,11 @@ =head1 B<--param> # ^^^^ constant.language.flags.regexp.perl # ^ punctuation.terminator.statement.perl CORE::tr -# ^^^^ variable.namespace.perl +# ^^^^ support.namespace.perl # ^^ punctuation.accessor.double-colon.perl # ^^ support.function.perl CORE::tr///g -# ^^^^ variable.namespace.perl +# ^^^^ support.namespace.perl # ^^ punctuation.accessor.double-colon.perl # ^^ support.function.perl # ^ punctuation.section.generic.begin.perl @@ -2098,11 +2098,11 @@ =head1 B<--param> # ^^^^ constant.language.flags.regexp.perl # ^ punctuation.terminator.statement.perl CORE::y -# ^^^^ variable.namespace.perl +# ^^^^ support.namespace.perl # ^^ punctuation.accessor.double-colon.perl # ^ support.function.perl CORE::y///g -# ^^^^ variable.namespace.perl +# ^^^^ support.namespace.perl # ^^ punctuation.accessor.double-colon.perl # ^ support.function.perl # ^ punctuation.section.generic.begin.perl @@ -2820,6 +2820,13 @@ =head1 B<--param> # ^^^^ meta.item-access.perl # ^ punctuation.section.item-access.end.perl + $CORE::foo +# ^^^^^^^^^^ meta.path.perl +# ^ punctuation.definition.variable.perl +# ^^^^ support.namespace.perl +# ^^ punctuation.accessor.double-colon.perl +# ^^^ variable.other.readwrite.perl + ###[ VARIABLE DEREFERENCING ]################################################# $$ref $$$refref $$$$refrefref @@ -3300,7 +3307,7 @@ =head1 B<--param> # ^^^^^^^^ meta.namespace.perl meta.path.perl # ^ - meta.namespace # ^^^^^^^ keyword.declaration.namespace.perl -# ^^ entity.name.namespace.perl +# ^^ variable.namespace.perl # ^^ punctuation.accessor.double-colon.perl # ^^^^ entity.name.namespace.perl # ^ punctuation.terminator.statement.perl @@ -3309,7 +3316,7 @@ =head1 B<--param> # ^^^^^^^^ meta.namespace.perl meta.path.perl # ^ - meta.namespace # ^^^^^^^ keyword.declaration.namespace.perl -# ^^ entity.name.namespace.perl +# ^^ variable.namespace.perl # ^^ punctuation.accessor.double-colon.perl # ^^^^ entity.name.namespace.perl # ^ punctuation.terminator.statement.perl @@ -3318,7 +3325,7 @@ =head1 B<--param> # ^^^^^^^^ meta.namespace.perl meta.path.perl # ^ - meta.namespace # ^^^^^^^ keyword.declaration.namespace.perl -# ^^ entity.name.namespace.perl +# ^^ variable.namespace.perl # ^^ punctuation.accessor.double-colon.perl # ^^^^ entity.name.namespace.perl # ^ punctuation.terminator.statement.perl @@ -3327,9 +3334,9 @@ =head1 B<--param> # ^^^^^^^^^^^^^^ meta.namespace.perl meta.path.perl # ^ - meta.namespace # ^^^^^^^ keyword.declaration.namespace.perl -# ^^ entity.name.namespace.perl +# ^^ variable.namespace.perl # ^^ punctuation.accessor.double-colon.perl -# ^^^^ entity.name.namespace.perl +# ^^^^ variable.namespace.perl # ^^ punctuation.accessor.double-colon.perl # ^^^^ entity.name.namespace.perl # ^ punctuation.terminator.statement.perl @@ -3339,7 +3346,7 @@ =head1 B<--param> NS::NAME # ^^ meta.namespace.perl - meta.path # ^^^^^^^^ meta.namespace.perl meta.path.perl -# ^^ entity.name.namespace.perl +# ^^ variable.namespace.perl # ^^ punctuation.accessor.double-colon.perl # ^^^^ entity.name.namespace.perl v5.24.1; @@ -3465,7 +3472,7 @@ =head1 B<--param> # ^^^^^^^^ meta.preprocessor.require.perl meta.path.perl # ^ - meta.preprocessor # ^^^^^^^ keyword.control.import.require.perl -# ^^^ entity.name.namespace.perl +# ^^^ variable.namespace.perl # ^^ punctuation.accessor.double-colon.perl # ^^^ entity.name.namespace.perl # ^ punctuation.terminator.statement.perl @@ -3476,7 +3483,7 @@ =head1 B<--param> # ^^ meta.preprocessor.require.perl - meta.path # ^^^^^^^^ meta.preprocessor.require.perl meta.path.perl # ^ - meta.preprocessor -# ^^^ entity.name.namespace.perl +# ^^^ variable.namespace.perl # ^^ punctuation.accessor.double-colon.perl # ^^^ entity.name.namespace.perl # ^ punctuation.terminator.statement.perl @@ -3516,7 +3523,7 @@ =head1 B<--param> CORE::require; # ^^^^^^ - meta.preprocessor # ^^^^^^^ meta.preprocessor.require.perl -# ^^^^ variable.namespace.perl +# ^^^^ support.namespace.perl # ^^ punctuation.accessor.double-colon.perl # ^^^^^^^ keyword.control.import.require.perl # ^ punctuation.terminator.statement.perl @@ -3545,7 +3552,7 @@ =head1 B<--param> # ^ meta.preprocessor.require.perl - meta.path # ^^^^^^^^^^^^^ - meta.preprocessor.require.perl # ^^^^^^^ keyword.control.import.require.perl -# ^ meta.path.perl entity.name.namespace.perl +# ^ meta.path.perl variable.namespace.perl # ^^ meta.path.perl punctuation.accessor.double-colon.perl # ^^^^^ meta.path.perl entity.name.namespace.perl # ^^^ keyword.operator.logical.perl @@ -3581,7 +3588,7 @@ =head1 B<--param> # ^^^^^^^^ meta.preprocessor.use.perl meta.path.perl # ^ - meta.preprocessor - meta.path # ^^^ keyword.control.import.use.perl -# ^^ entity.name.namespace.perl +# ^^ variable.namespace.perl # ^^ punctuation.accessor.double-colon.perl # ^^^^ entity.name.namespace.perl # ^ punctuation.terminator.statement.perl @@ -3592,7 +3599,7 @@ =head1 B<--param> # ^^^^^^^^^ meta.preprocessor.use.perl meta.path.perl # ^ - meta.preprocessor - meta.path # ^^^ keyword.control.import.use.perl -# ^^^^^^^^ entity.name.namespace.perl +# ^^^^^^^^ variable.namespace.perl # ^^ meta.path.perl punctuation.accessor.double-colon.perl # ^^^^^^^^ entity.name.namespace.perl # ^^^ variable.namespace.perl @@ -3602,7 +3609,7 @@ =head1 B<--param> CORE::use; # ^^^^^^ - meta.preprocessor # ^^^ meta.preprocessor.use.perl -# ^^^^ variable.namespace.perl +# ^^^^ support.namespace.perl # ^^ punctuation.accessor.double-colon.perl # ^^^ keyword.control.import.use.perl # ^ punctuation.terminator.statement.perl @@ -3624,7 +3631,7 @@ =head1 B<--param> CORE::no; # ^^^^^^ - meta.preprocessor # ^^ meta.preprocessor.no.perl -# ^^^^ variable.namespace.perl +# ^^^^ support.namespace.perl # ^^ punctuation.accessor.double-colon.perl # ^^ keyword.control.import.no.perl # ^ punctuation.terminator.statement.perl @@ -3692,7 +3699,7 @@ =head1 B<--param> # ^ punctuation.terminator.statement.perl # ^ punctuation.section.block.end.perl CORE::my -# ^^^^ variable.namespace.perl +# ^^^^ support.namespace.perl # ^^ punctuation.accessor.double-colon.perl # ^^ keyword.declaration.variable.perl core::my @@ -4605,7 +4612,7 @@ =head1 B<--param> CORE::sub ; # ^^^^^^ - meta.function.perl # ^^^^ meta.function.perl -# ^^^^ variable.namespace.perl +# ^^^^ support.namespace.perl # ^^ punctuation.accessor.double-colon.perl # ^^^ keyword.declaration.function.perl # ^ punctuation.terminator.statement.perl @@ -5423,7 +5430,7 @@ =head1 B<--param> # ^ punctuation.section.group.end.perl # ^ punctuation.section.block.begin.perl CORE::break; -# ^^^^ variable.namespace.perl +# ^^^^ support.namespace.perl # ^^ punctuation.accessor.double-colon.perl # ^^^^^ keyword.control.flow.break.perl } From 5eb17cfee5624f1e74e7176a27e4606d6373653f Mon Sep 17 00:00:00 2001 From: deathaxe Date: Wed, 1 Jun 2022 17:15:32 +0200 Subject: [PATCH 07/22] [CSS] Add viewport units (#3418) Fixes #3417 --- CSS/CSS.sublime-syntax | 2 +- CSS/syntax_test_css.css | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CSS/CSS.sublime-syntax b/CSS/CSS.sublime-syntax index 9baca2cd588..82e4f6b90b5 100644 --- a/CSS/CSS.sublime-syntax +++ b/CSS/CSS.sublime-syntax @@ -64,7 +64,7 @@ variables: | {{viewport_percentage_lengths}} ) font_relative_lengths: (?i:cap|ch|em|ex|ic|lh|rem|rlh)\b - viewport_percentage_lengths: (?i:vh|vw|vi|vb|vmin|vmax)\b + viewport_percentage_lengths: (?i:[sld]?(?:vh|vw|vi|vb|vmin|vmax))\b absolute_lengths: (?i:cm|mm|q|in|pt|pc|px|fr)\b angle_units: (?i:deg|grad|rad|turn)\b duration_units: (?i:s|ms)\b diff --git a/CSS/syntax_test_css.css b/CSS/syntax_test_css.css index 11990ee683d..9f6af1f4949 100644 --- a/CSS/syntax_test_css.css +++ b/CSS/syntax_test_css.css @@ -1645,6 +1645,14 @@ top: 0.9rlh; /* ^^^^^^ meta.number.float.decimal.css */ /* ^^^ constant.numeric.value.css */ +/* ^^^ constant.numeric.suffix.css */ + top: 1.0vh; +/* ^^ constant.numeric.suffix.css */ + top: 1.0svh; +/* ^^^ constant.numeric.suffix.css */ + top: 1.0dvh; +/* ^^^ constant.numeric.suffix.css */ + top: 1.0lvh; /* ^^^ constant.numeric.suffix.css */ } From ce44f56c091fe246fceafa0cd819d40ff799aa36 Mon Sep 17 00:00:00 2001 From: jwortmann Date: Wed, 1 Jun 2022 18:55:50 +0200 Subject: [PATCH 08/22] [LaTeX] Improve support for string variables in BibTeX files (#3419) * Add support for variables and concatenation operator in BibTeX entries * Adjust scope name for variable definition to `entity.name.constant` * Allow lowercased `@string` keyword * Update scope name for integer numbers to latest convention --- LaTeX/Bibtex.sublime-syntax | 27 ++++++++++++++++++++++----- LaTeX/syntax_test_bibtex.bib | 14 ++++++++++++-- 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/LaTeX/Bibtex.sublime-syntax b/LaTeX/Bibtex.sublime-syntax index c9eb0e54e52..16356f1fda4 100644 --- a/LaTeX/Bibtex.sublime-syntax +++ b/LaTeX/Bibtex.sublime-syntax @@ -16,6 +16,9 @@ first_line_match: |- ^ \s* \%+ .*? -\*- .*? \bbibtex\b .*? -\*- # editorconfig ) +variables: + var: '\b[a-zA-Z]\w*' + contexts: main: - match: "@Comment" @@ -25,12 +28,12 @@ contexts: - meta_scope: comment.line.at-sign.bibtex - match: $\n? pop: true - - match: '((@)String)\s*(\{)\s*([a-zA-Z]*)' + - match: '((@)[Ss]tring)\s*(\{)\s*({{var}})' captures: 1: keyword.other.string-constant.bibtex 2: punctuation.definition.keyword.bibtex 3: punctuation.section.string-constant.begin.bibtex - 4: variable.other.bibtex + 4: entity.name.constant.bibtex push: - meta_scope: meta.string-constant.braces.bibtex - match: '\}' @@ -38,12 +41,14 @@ contexts: 0: punctuation.section.string-constant.end.bibtex pop: true - include: string_content - - match: '((@)String)\s*(\()\s*([a-zA-Z]*)' + - include: variables + - include: operators + - match: '((@)[Ss]tring)\s*(\()\s*({{var}})' captures: 1: keyword.other.string-constant.bibtex 2: punctuation.definition.keyword.bibtex 3: punctuation.section.string-constant.begin.bibtex - 4: variable.other.bibtex + 4: entity.name.constant.bibtex push: - meta_scope: meta.string-constant.parenthesis.bibtex - match: \) @@ -51,6 +56,8 @@ contexts: 0: punctuation.section.string-constant.end.bibtex pop: true - include: string_content + - include: variables + - include: operators - match: '((@)[a-zA-Z]+)\s*(\{)\s*([^\s,]*)' captures: 1: keyword.other.entry-type.bibtex @@ -76,6 +83,8 @@ contexts: pop: true - include: string_content - include: integer + - include: variables + - include: operators - match: \, scope: punctuation.separator.sequence.bibtex - match: '((@)[a-zA-Z]+)\s*(\()\s*([^\s,]*)' @@ -103,6 +112,8 @@ contexts: pop: true - include: string_content - include: integer + - include: variables + - include: operators - match: \, scope: punctuation.separator.sequence.bibtex - match: '[^@\n]' @@ -112,7 +123,13 @@ contexts: pop: true integer: - match: \d+ - scope: constant.numeric.bibtex + scope: meta.number.integer.decimal.bibtex constant.numeric.value.bibtex + variables: + - match: '{{var}}' + scope: variable.other.constant.bibtex + operators: + - match: \# + scope: keyword.operator.concatenation.bibtex nested_braces: - match: '\{' captures: diff --git a/LaTeX/syntax_test_bibtex.bib b/LaTeX/syntax_test_bibtex.bib index 560df1a57b7..9a766d58156 100644 --- a/LaTeX/syntax_test_bibtex.bib +++ b/LaTeX/syntax_test_bibtex.bib @@ -1,5 +1,11 @@ % SYNTAX TEST "Packages/LaTeX/Bibtex.sublime-syntax" +@string(mar = "march") +@string(aw = "Addison-Wesley") +%<- keyword.other.string-constant.bibtex punctuation.definition.keyword.bibtex +%^^^^^^ keyword.other.string-constant.bibtex +% ^^ entity.name.constant.bibtex + @book{knuth97, %<- keyword.other.entry-type.bibtex punctuation.definition.keyword.bibtex %^^^^ keyword.other.entry-type.bibtex @@ -14,7 +20,11 @@ @book{knuth97 % ^ punctuation.separator.sequence.bibtex title = {The Art of Computer Programming, Vol. 1: Fundamental Algorithms}, edition = {3}, - publisher = {Addison-Wesley}, - date = {1997}, + publisher = aw, +% ^^ variable.other.constant.bibtex + date = 1997, +% ^^^^ meta.number.integer.decimal.bibtex constant.numeric.value.bibtex + month = "1~" # mar, +% ^ keyword.operator.concatenation.bibtex isbn = {978-0-201-89683-1} } From dfb5099e3ad3cf06720074450b45f6e47d00fcbc Mon Sep 17 00:00:00 2001 From: deathaxe Date: Fri, 3 Jun 2022 09:09:23 +0200 Subject: [PATCH 09/22] [C/C++] Exclude macros from enumeration constants (#3410) Fixes #3369 Some enumeration constants have been detected as MACROS due to heuristics in `expressions`. This commit therefore restricts related contexts to match valid enumeration constants only. --- C++/C++.sublime-syntax | 4 +++- C++/C.sublime-syntax | 4 +++- C++/syntax_test_c.c | 8 ++++++++ C++/syntax_test_cpp.cpp | 8 ++++++++ Objective-C/Objective-C++.sublime-syntax | 4 +++- Objective-C/Objective-C.sublime-syntax | 4 +++- Objective-C/syntax_test_objc++.mm | 8 ++++++++ Objective-C/syntax_test_objc.m | 8 ++++++++ 8 files changed, 44 insertions(+), 4 deletions(-) diff --git a/C++/C++.sublime-syntax b/C++/C++.sublime-syntax index 7589de7ab6f..e7e31058446 100644 --- a/C++/C++.sublime-syntax +++ b/C++/C++.sublime-syntax @@ -334,12 +334,14 @@ contexts: - include: expressions statements-enum: + - include: comments - include: preprocessor-statements - include: scope:source.c#label - match: '{{identifier}}' scope: entity.name.constant.c++ push: constant-value - - include: expressions + - match: ',' + scope: punctuation.separator.c++ constant-value: - match: (?=[,;}]) diff --git a/C++/C.sublime-syntax b/C++/C.sublime-syntax index d82fdff22e8..301fd221c43 100644 --- a/C++/C.sublime-syntax +++ b/C++/C.sublime-syntax @@ -688,13 +688,15 @@ contexts: - include: expressions data-structures-body-enum: + - include: comments - include: preprocessor-data-structures - match: '(?={{before_tag}})' push: data-structures - match: '{{identifier}}' scope: entity.name.constant.c push: constant-value - - include: expressions + - match: ',' + scope: punctuation.separator.c constant-value: - match: (?=[,;}]) diff --git a/C++/syntax_test_c.c b/C++/syntax_test_c.c index 319a64ebb95..a816b242194 100644 --- a/C++/syntax_test_c.c +++ b/C++/syntax_test_c.c @@ -40,6 +40,14 @@ enum { kFoo = FOO, kBar = BAR }; /* ^ keyword.operator.assignment.c */ /* ^^^ - entity.name.constant */ +enum { + FOO, +/* ^^^ entity.name.constant.c */ +/* ^ punctuation.separator.c */ + BAR +/* ^^^ entity.name.constant.c */ +}; + typedef enum state { DEAD, ALIVE } State; /* <- keyword.declaration /* ^ entity.name.enum */ diff --git a/C++/syntax_test_cpp.cpp b/C++/syntax_test_cpp.cpp index e46ed087590..47e77aae15f 100644 --- a/C++/syntax_test_cpp.cpp +++ b/C++/syntax_test_cpp.cpp @@ -2010,6 +2010,14 @@ class FooBar { and_now_method_name2(); /* ^ entity.name.function */ + enum { + FOO, + /* ^^^ entity.name.constant.c++ */ + /* ^ punctuation.separator.c++ */ + BAR + /* ^^^ entity.name.constant.c++ */ + }; + enum /* ^^^^ meta.enum keyword.declaration */ { diff --git a/Objective-C/Objective-C++.sublime-syntax b/Objective-C/Objective-C++.sublime-syntax index 461dcfb0639..e244d8b9c2c 100644 --- a/Objective-C/Objective-C++.sublime-syntax +++ b/Objective-C/Objective-C++.sublime-syntax @@ -118,12 +118,14 @@ contexts: - include: expressions statements-enum: + - include: comments - include: preprocessor-statements - include: scope:source.c#label - match: '{{identifier}}' scope: entity.name.constant.objc++ push: constant-value - - include: expressions + - match: ',' + scope: punctuation.separator.objc++ constant-value: - match: (?=[,;}]) diff --git a/Objective-C/Objective-C.sublime-syntax b/Objective-C/Objective-C.sublime-syntax index 21e6cdcee41..7fa1602c6ad 100644 --- a/Objective-C/Objective-C.sublime-syntax +++ b/Objective-C/Objective-C.sublime-syntax @@ -784,13 +784,15 @@ contexts: - include: expressions data-structures-body-enum: + - include: comments - include: preprocessor-data-structures - match: '(?={{before_tag}})' push: data-structures - match: '{{identifier}}' scope: entity.name.constant.objc push: constant-value - - include: expressions + - match: ',' + scope: punctuation.separator.objc constant-value: - match: (?=[,;}]) diff --git a/Objective-C/syntax_test_objc++.mm b/Objective-C/syntax_test_objc++.mm index b7a1ab1d958..fb18308e2e2 100644 --- a/Objective-C/syntax_test_objc++.mm +++ b/Objective-C/syntax_test_objc++.mm @@ -1962,6 +1962,14 @@ auto g() -> std::vector override final { and_now_method_name2(); /* ^ entity.name.function */ + enum { + FOO, + /* ^^^ entity.name.constant.objc++ */ + /* ^ punctuation.separator.objc++ */ + BAR + /* ^^^ entity.name.constant.objc++ */ + }; + enum /* ^^^^ meta.enum keyword.declaration */ { diff --git a/Objective-C/syntax_test_objc.m b/Objective-C/syntax_test_objc.m index f7c02f00c53..2deaffcf198 100644 --- a/Objective-C/syntax_test_objc.m +++ b/Objective-C/syntax_test_objc.m @@ -46,6 +46,14 @@ int main(){ /* ^ entity.name.constant.objc */ /* ^ entity.name.constant.objc */ +enum { + FOO, +/* ^^^ entity.name.constant.objc */ +/* ^ punctuation.separator.objc */ + BAR +/* ^^^ entity.name.constant.objc */ +}; + struct __declspec(dllimport) X {}; /* ^ storage.modifier */ /* ^ entity.name.struct */ From f4fefb52bcbdfa7502e3ee25701a2cb8fa162038 Mon Sep 17 00:00:00 2001 From: jwortmann Date: Sun, 5 Jun 2022 20:48:52 +0200 Subject: [PATCH 10/22] [Matlab] Adjust scope for path in qualified base class (#3422) Align with other syntaxes and scope naming guidelines. --- Matlab/Matlab.sublime-syntax | 17 +++++++++++++++++ Matlab/syntax_test_matlab.matlab | 9 +++++++++ 2 files changed, 26 insertions(+) diff --git a/Matlab/Matlab.sublime-syntax b/Matlab/Matlab.sublime-syntax index 72f31084526..51dca6da2a7 100644 --- a/Matlab/Matlab.sublime-syntax +++ b/Matlab/Matlab.sublime-syntax @@ -446,6 +446,10 @@ contexts: - match: (?=\S) pop: 1 + immediately-pop: + - match: '' + pop: 1 + ###[ COMMENTS AND LINE CONTINUATION ]########################################### comments: @@ -772,11 +776,24 @@ contexts: - include: line-continuations - match: '{{eol}}' set: class-body + - match: (?={{identifier}}\.) + push: qualified-superclass - match: '{{identifier}}' scope: entity.other.inherited-class.matlab - match: \& scope: punctuation.separator.sequence.matlab + qualified-superclass: + - meta_scope: meta.path.matlab + - match: '({{identifier}})(\.)' + captures: + 1: variable.namespace.matlab + 2: punctuation.accessor.dot.matlab + - match: '{{identifier}}' + scope: entity.other.inherited-class.matlab + pop: 1 + - include: immediately-pop + class-attributes-list: - meta_scope: meta.attributes.matlab - include: line-continuations diff --git a/Matlab/syntax_test_matlab.matlab b/Matlab/syntax_test_matlab.matlab index cf0c683b6c0..bf47b430c7d 100644 --- a/Matlab/syntax_test_matlab.matlab +++ b/Matlab/syntax_test_matlab.matlab @@ -115,6 +115,15 @@ classdef ClassName ... comment % ^^^^^^^^^^ meta.class.matlab entity.other.inherited-class.matlab end +classdef MyClass < matlab.mixin.Copyable +% ^^^^^^^^^^^^^^^^^^^^^ meta.path.matlab - meta.path meta.path +% ^^^^^^ variable.namespace.matlab +% ^ punctuation.accessor.dot.matlab +% ^^^^^ variable.namespace.matlab +% ^ punctuation.accessor.dot.matlab +% ^^^^^^^^ entity.other.inherited-class.matlab +end + %--------------------------------------------- % Parens, brackets, braces, punctuation From 9ebbc13d3b29c0512446eb2d573e167c50b1ba30 Mon Sep 17 00:00:00 2001 From: jwortmann Date: Sun, 5 Jun 2022 20:49:11 +0200 Subject: [PATCH 11/22] [Python] Adjust scope for module name in qualified base class (#3421) Align with other syntaxes and scope naming guidelines. --- Python/Python.sublime-syntax | 14 ++++++++++---- Python/syntax_test_python.py | 4 +++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Python/Python.sublime-syntax b/Python/Python.sublime-syntax index b9a33053711..6d9cc28e8b5 100644 --- a/Python/Python.sublime-syntax +++ b/Python/Python.sublime-syntax @@ -1080,14 +1080,20 @@ contexts: captures: 1: variable.parameter.class-inheritance.python 2: keyword.operator.assignment.python - - match: (?={{path}}) + - match: (?={{identifier}} *\.) push: - - meta_scope: entity.other.inherited-class.python - - match: '{{identifier}}(?: *(\.) *)?' + - meta_scope: meta.path.python + - match: '({{identifier}}) *(\.) *' captures: - 1: punctuation.accessor.dot.python + 1: variable.namespace.python + 2: punctuation.accessor.dot.python + - match: '{{identifier}}' + scope: entity.other.inherited-class.python + pop: true - match: '' pop: true + - match: '{{identifier}}' + scope: entity.other.inherited-class.python - include: expression-in-a-group functions: diff --git a/Python/syntax_test_python.py b/Python/syntax_test_python.py index 49f17346253..363cb337b56 100644 --- a/Python/syntax_test_python.py +++ b/Python/syntax_test_python.py @@ -1609,8 +1609,10 @@ class MyClass(Inherited, \ # ^ punctuation.separator.inheritance # ^ punctuation.separator.continuation.line.python module . Inherited2, metaclass=ABCMeta): -# ^^^^^^^^^^^^^^^^^^^ entity.other.inherited-class +# ^^^^^^^^^^^^^^^^^^^ meta.path - meta.path meta.path +# ^^^^^^ variable.namespace - entity # ^ punctuation.accessor.dot +# ^^^^^^^^^^ entity.other.inherited-class # ^ punctuation.separator.inheritance # ^^^^^^^^^ variable.parameter.class-inheritance # ^ keyword.operator.assignment From b61b13b945562d9b1c19bd0bde992e6fd81c8484 Mon Sep 17 00:00:00 2001 From: Jack Cherng Date: Tue, 7 Jun 2022 23:49:45 +0800 Subject: [PATCH 12/22] [Git Formats] Add scope for newline at section end (#3423) Co-authored-by: deathaxe --- Git Formats/Git Config - Fold.tmPreferences | 21 ++++++++ .../Git Config - Symbol List.tmPreferences | 2 +- Git Formats/Git Config.sublime-syntax | 13 ++++- Git Formats/tests/syntax_test_git_config | 51 ++++++++++--------- 4 files changed, 61 insertions(+), 26 deletions(-) create mode 100644 Git Formats/Git Config - Fold.tmPreferences diff --git a/Git Formats/Git Config - Fold.tmPreferences b/Git Formats/Git Config - Fold.tmPreferences new file mode 100644 index 00000000000..78e458b4a39 --- /dev/null +++ b/Git Formats/Git Config - Fold.tmPreferences @@ -0,0 +1,21 @@ + + + + scope + text.git.config + settings + + foldScopes + + + begin + meta.section meta.brackets punctuation.definition.brackets.end + end + meta.section meta.brackets punctuation.definition.brackets.begin + excludeTrailingNewlines + + + + + + diff --git a/Git Formats/Git Config - Symbol List.tmPreferences b/Git Formats/Git Config - Symbol List.tmPreferences index 5dbea2e9819..796ee644ded 100644 --- a/Git Formats/Git Config - Symbol List.tmPreferences +++ b/Git Formats/Git Config - Symbol List.tmPreferences @@ -4,7 +4,7 @@ name Symbol List scope - meta.brackets.git.config + meta.section.header.git.config meta.brackets.git.config settings showInSymbolList diff --git a/Git Formats/Git Config.sublime-syntax b/Git Formats/Git Config.sublime-syntax index 05ccc314d32..e6b805b369e 100644 --- a/Git Formats/Git Config.sublime-syntax +++ b/Git Formats/Git Config.sublime-syntax @@ -41,7 +41,14 @@ contexts: section-header: - match: \[ scope: punctuation.definition.brackets.begin.git.config - set: [expect-line-end, section-header-end, section-name] + set: [section-header-meta, section-header-end, section-name] + + section-header-meta: + - meta_scope: meta.section.header.git.config + - match: $\n? + pop: 1 + - match: \S + scope: invalid.illegal.expected.eol.git.config section-header-end: - meta_scope: meta.brackets.git.config @@ -99,13 +106,14 @@ contexts: - match: (?=^\s*\[) # start of new section pop: 1 - match: \] - scope: punctuation.definition.brackets.end.git.config invalid.illegal.stray-bracket.git.config + scope: invalid.illegal.stray-bracket.git.config ##[ SECTION BODY ]##################################################### # changed = red # untracked = bold green key-color-pair: + - meta_scope: meta.section.body.git.config - match: ^(\s*)({{variable_name}})(\s*(\=)\s*) captures: 1: meta.mapping.git.config @@ -120,6 +128,7 @@ contexts: # key = val key-value-pair: + - meta_scope: meta.section.body.git.config - match: ^(\s*)({{variable_name}})(\s*(\=)\s*) captures: 1: meta.mapping.git.config diff --git a/Git Formats/tests/syntax_test_git_config b/Git Formats/tests/syntax_test_git_config index b24a4a115b6..5f328877a42 100644 --- a/Git Formats/tests/syntax_test_git_config +++ b/Git Formats/tests/syntax_test_git_config @@ -9,22 +9,26 @@ #^^^^^^^^^^^^^^^^^^ comment.line # SECTION HEADER TESTS -[section] -# <- meta.brackets punctuation.definition.brackets.begin -#^^^^^^^ meta.brackets entity.name -# ^ meta.brackets punctuation.definition.brackets.end -# ^ -meta.brackets +[section] # color section +# <- meta.section.header meta.brackets punctuation.definition.brackets.begin +#^^^^^^^ meta.section.header meta.brackets entity.name.section - punctuation +# ^ meta.section.header meta.brackets punctuation.definition.brackets.end +# ^^^^^^^^^^^^^^^^^^ meta.section.header - meta.brackets +# ^ punctuation.definition.comment +# ^^^^^^^^^^^^^^^^ comment.line [section "subsection"] -# <- meta.brackets punctuation.definition.brackets.begin -#^^^^^^^^^^^^^ meta.brackets +# <- meta.section.header meta.brackets punctuation.definition.brackets.begin +#^^^^^^^^^^^^^^^^^^^^^ meta.section.header meta.brackets +# ^ meta.section.header - meta.brackets #^^^^^^^ entity.name # ^^^^^^^^^^^^ string.quoted.double # ^ punctuation.definition.string.begin # ^ punctuation.definition.string.end # ^ punctuation.definition.brackets.end [section \"subsection"] -# <- meta.brackets punctuation.definition.brackets.begin -#^^^^^^^^^^^^^ meta.brackets +# <- meta.section.header meta.brackets punctuation.definition.brackets.begin +#^^^^^^^^^^^^^^^^^^^^^^ meta.section.header meta.brackets +# ^ meta.section.header - meta.brackets #^^^^^^^ entity.name # ^ invalid.illegal [section "\slashes\are\legal"] @@ -52,9 +56,9 @@ # LEGACY SECTION HEADER SYNTAX [section.subsection.subsubsection] -# <- meta.brackets -#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.brackets -# ^ - meta.brackets +# <- meta.section.header +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.section.header meta.brackets +# ^ meta.section.header - meta.brackets # <- punctuation.definition.brackets.begin #^^^^^^^ entity.name.section # ^ punctuation.accessor.dot @@ -65,9 +69,9 @@ # LEGACY SECTION HEADER SYNTAX [se\ct\\ion.s"ub\se\\ct\"ion -# <- meta.brackets -#^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.brackets -# ^ - meta.brackets +# <- meta.section.header +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.section.header meta.brackets +# ^ - meta.section.header # <- punctuation.definition.brackets.begin #^^ entity.name.section # ^ invalid.illegal.section-name @@ -88,14 +92,14 @@ # COLOR TESTS [color "diff"] -# <- meta.brackets punctuation.definition.brackets.begin -#^^^^^^^^^^^^^ meta.brackets +# <- meta.section.header meta.brackets punctuation.definition.brackets.begin +#^^^^^^^^^^^^^ meta.section.header meta.brackets #^^^^^ entity.name # ^^^^^^ string.quoted.double # ^ punctuation.definition.string.begin # ^ punctuation.definition.string.end # ^ punctuation.definition.brackets.end -# ^ -meta.brackets +# ^ meta.section.header - meta.brackets old = red # <- meta.mapping #^^^^^^^^^^^^ meta.mapping @@ -212,11 +216,11 @@ # ILLEGAL NEWLINE IN SECTION TEST [section -#^^^^^^^^ meta.brackets +#^^^^^^^^ meta.section.header #^^^^^^^ entity.name # ^ invalid.illegal.unexpected.eol ] -# <- punctuation.definition.brackets.end invalid.illegal.stray-bracket +# <- invalid.illegal.stray-bracket # # INVALID TEXT AFTER SECTION TEST [stray-bracket]] and anything # comment @@ -230,7 +234,7 @@ # STRAY BRACKET TEST stray-bracket] -# ^ punctuation.definition.brackets.end invalid.illegal.stray-bracket +# ^ invalid.illegal.stray-bracket # STRING TESTS [strings] @@ -454,10 +458,11 @@ stray-bracket] # REAL WORLD SAMPLE TESTS [alias] -# <- meta.brackets punctuation.definition.brackets.begin -#^^^^^^ meta.brackets +# <- meta.section.header meta.brackets punctuation.definition.brackets.begin +#^^^^^^ meta.section.header meta.brackets #^^^^^ entity.name # ^ punctuation.definition.brackets.end +# ^ meta.section.header - meta.brackets branch-author = for-each-ref --format='%(committerdate) %09 %(authorname) %09 %(refname)' # <- meta.mapping #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.mapping From ab2fcb6998f2922b4f84f89110ffdeeb3dd40acd Mon Sep 17 00:00:00 2001 From: Thomas Smith Date: Fri, 10 Jun 2022 10:53:36 -0400 Subject: [PATCH 13/22] [TypeScript] Allow numbers as object/interface type keys (#3427) --- JavaScript/TypeScript.sublime-syntax | 3 ++- JavaScript/tests/syntax_test_typescript.ts | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/JavaScript/TypeScript.sublime-syntax b/JavaScript/TypeScript.sublime-syntax index bd20a220b98..d533b147aa3 100644 --- a/JavaScript/TypeScript.sublime-syntax +++ b/JavaScript/TypeScript.sublime-syntax @@ -394,7 +394,7 @@ contexts: - function-declaration-expect-parameters - ts-type-parameter-list - - match: (?={{identifier_start}}|['"]) + - match: (?={{identifier_start}}|['"]|\d) push: - - match: (?=[<(]) set: @@ -411,6 +411,7 @@ contexts: scope: variable.other.readwrite.js pop: true - include: literal-string + - include: literal-number ts-enum: - match: enum{{identifier_break}} diff --git a/JavaScript/tests/syntax_test_typescript.ts b/JavaScript/tests/syntax_test_typescript.ts index e1716a3a82e..f93a8a90105 100644 --- a/JavaScript/tests/syntax_test_typescript.ts +++ b/JavaScript/tests/syntax_test_typescript.ts @@ -226,6 +226,14 @@ import foo; // ^ punctuation.separator.type // ^^^ meta.type support.type.any // ^ punctuation.separator + + 1: any, +// ^ meta.number.integer.decimal +// ^ constant.numeric.value +// ^ punctuation.separator.type +// ^^^^ meta.type +// ^^^ support.type.any +// ^ punctuation.separator } // ^ meta.block punctuation.section.block.end From 0207285b9bb2c5ef8a367f4d362a20c9f206163c Mon Sep 17 00:00:00 2001 From: deathaxe Date: Fri, 10 Jun 2022 16:53:53 +0200 Subject: [PATCH 14/22] [JavaScript] Add typescript shebang support (#3428) This commit adds `ts-node` and `ts-node-script` to `first_line_match` and highlights it via shebang-body context. References `ts-node`: https://www.npmjs.com/package/ts-node#shebang `ts-node-script`: https://deepkit.io/documentation/framework --- JavaScript/JavaScript.sublime-syntax | 8 +++++--- JavaScript/TypeScript.sublime-syntax | 5 ++++- JavaScript/tests/syntax_test_shebang.js | 4 ++++ JavaScript/tests/syntax_test_shebang.ts | 4 ++++ 4 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 JavaScript/tests/syntax_test_shebang.js create mode 100644 JavaScript/tests/syntax_test_shebang.ts diff --git a/JavaScript/JavaScript.sublime-syntax b/JavaScript/JavaScript.sublime-syntax index 1a46b9053cb..13c78d36090 100644 --- a/JavaScript/JavaScript.sublime-syntax +++ b/JavaScript/JavaScript.sublime-syntax @@ -12,11 +12,13 @@ file_extensions: first_line_match: |- (?xi: - ^ \#! .* \b(node|js)\b # shebang - | ^ \s* // .*? -\*- .*? \b(js|javascript)\b .*? -\*- # editorconfig + ^ \#! .* \b(?:node|js)\b # shebang + | ^ \s* // .*? -\*- .*? \b(?:js|javascript)\b .*? -\*- # editorconfig ) variables: + shebang_lang: \b(?:node|js)\b + bin_digit: '[01_]' oct_digit: '[0-7_]' dec_digit: '[0-9_]' @@ -221,7 +223,7 @@ contexts: - meta_include_prototype: false - meta_scope: comment.line.shebang.js # Note: Keep sync with first_line_match! - - match: \b(node|js)\b + - match: '{{shebang_lang}}' scope: constant.language.shebang.js - match: \n pop: 1 diff --git a/JavaScript/TypeScript.sublime-syntax b/JavaScript/TypeScript.sublime-syntax index d533b147aa3..907aac48095 100644 --- a/JavaScript/TypeScript.sublime-syntax +++ b/JavaScript/TypeScript.sublime-syntax @@ -11,10 +11,13 @@ file_extensions: first_line_match: |- (?xi: - ^ \s* // .*? -\*- .*? \b(ts|typescript)\b .*? -\*- # editorconfig + ^ \#! .* \bts-node(?:-script)?\b # shebang + | ^ \s* // .*? -\*- .*? \b(ts|typescript)\b .*? -\*- # editorconfig ) variables: + shebang_lang: \bts-node(?:-script)?\b + dot_accessor: (?:[?!]?\.) possible_arrow_function_begin: (?:\(|{{identifier_start}}|<) diff --git a/JavaScript/tests/syntax_test_shebang.js b/JavaScript/tests/syntax_test_shebang.js new file mode 100644 index 00000000000..d44a4e0c0e5 --- /dev/null +++ b/JavaScript/tests/syntax_test_shebang.js @@ -0,0 +1,4 @@ +#!node SYNTAX TEST "Packages/JavaScript/JavaScript.sublime-syntax" +#!node <- comment.line.shebang.js punctuation.definition.comment.js + #!node <- comment.line.shebang.js constant.language.shebang.js + #!node <- comment.line.shebang.js - constant.language diff --git a/JavaScript/tests/syntax_test_shebang.ts b/JavaScript/tests/syntax_test_shebang.ts new file mode 100644 index 00000000000..bb6ef108c25 --- /dev/null +++ b/JavaScript/tests/syntax_test_shebang.ts @@ -0,0 +1,4 @@ +#!ts-node SYNTAX TEST "Packages/JavaScript/TypeScript.sublime-syntax" +#!ts-node <- comment.line.shebang.js punctuation.definition.comment.js + #!ts-node <- comment.line.shebang.js constant.language.shebang.js + #!ts-node <- comment.line.shebang.js - constant.language From ec6102cac417dc6b7e0cad4b431a27793903ffc7 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Tue, 14 Jun 2022 19:41:32 +0200 Subject: [PATCH 15/22] [Git Formats] Fix key-value punctuation (#3424) This commit renames scope of `=` in git config files from `keyword.operator.assignment` to `punctuation.separator.key-value` as those are scoped `meta.mapping` already. --- Git Formats/Git Config.sublime-syntax | 4 +- Git Formats/tests/syntax_test_git_config | 64 ++++++++++++------------ 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/Git Formats/Git Config.sublime-syntax b/Git Formats/Git Config.sublime-syntax index e6b805b369e..0f1bff4e384 100644 --- a/Git Formats/Git Config.sublime-syntax +++ b/Git Formats/Git Config.sublime-syntax @@ -119,7 +119,7 @@ contexts: 1: meta.mapping.git.config 2: meta.mapping.key.git.config variable.other.readwrite.git.config 3: meta.mapping.git.config - 4: keyword.operator.assignment.git.config + 4: punctuation.separator.key-value.git.config push: - meta_content_scope: meta.mapping.value.git.config - include: color-value @@ -134,7 +134,7 @@ contexts: 1: meta.mapping.git.config 2: meta.mapping.key.git.config variable.other.readwrite.git.config 3: meta.mapping.git.config - 4: keyword.operator.assignment.git.config + 4: punctuation.separator.key-value.git.config push: - meta_content_scope: meta.mapping.value.git.config - include: other-value diff --git a/Git Formats/tests/syntax_test_git_config b/Git Formats/tests/syntax_test_git_config index 5f328877a42..f660ab381e1 100644 --- a/Git Formats/tests/syntax_test_git_config +++ b/Git Formats/tests/syntax_test_git_config @@ -105,16 +105,16 @@ #^^^^^^^^^^^^ meta.mapping # ^^^ variable.other.readwrite # ^ -variable.other.readwrite -# ^ keyword.operator.assignment -# ^ -keyword.operator.assignment +# ^ punctuation.separator.key-value +# ^ -punctuation.separator.key-value # ^^^ meta.mapping.value support.constant.color new = #00aa00 # this should be a comment # <- meta.mapping #^^^^^^^^^^^^^^^^ meta.mapping # ^^^ variable.other.readwrite # ^ -variable.other.readwrite -# ^ keyword.operator.assignment -# ^ -keyword.operator.assignment +# ^ punctuation.separator.key-value +# ^ -punctuation.separator.key-value # ^ comment.line punctuation.definition.comment # ^^^^^^^ comment.line commit = bold yellow @@ -122,8 +122,8 @@ #^^^^^^^^^^^^^^^^^^^^^^^ meta.mapping # ^^^^^^ variable.other.readwrite # ^ -variable.other.readwrite -# ^ keyword.operator.assignment -# ^ -keyword.operator.assignment +# ^ punctuation.separator.key-value +# ^ -punctuation.separator.key-value # ^^^^^^^^^^^ meta.mapping.value # ^^^^ support.constant.color-attribute # ^^^^^^ support.constant.color @@ -164,7 +164,7 @@ quoted = "\\ \" \b \n \t" #^^^^^^^^^^^^^^^^^^^^^^^^^ meta.mapping # ^^^^^^ variable.other.readwrite -# ^ keyword.operator.assignment +# ^ punctuation.separator.key-value # ^^^^^^^^^^^^^^^^ meta.mapping.value string.quoted.double # ^^ constant.character.escape # ^^ constant.character.escape @@ -186,32 +186,32 @@ foo = true #^^^^^^^^^^^^^ meta.mapping # ^^^ variable.other.readwrite -# ^ keyword.operator.assignment +# ^ punctuation.separator.key-value # ^^^^ meta.mapping.value constant.language foo = false #^^^^^^^^^^^^^^ meta.mapping # ^^^ variable.other.readwrite -# ^ keyword.operator.assignment +# ^ punctuation.separator.key-value # ^^^^^ meta.mapping.value constant.language foo = on #^^^^^^^^^^^ meta.mapping # ^^^ variable.other.readwrite -# ^ keyword.operator.assignment +# ^ punctuation.separator.key-value # ^^ meta.mapping.value constant.language foo = off #^^^^^^^^^^^^ meta.mapping # ^^^ variable.other.readwrite -# ^ keyword.operator.assignment +# ^ punctuation.separator.key-value # ^^^ meta.mapping.value constant.language foo = no #^^^^^^^^^^^ meta.mapping # ^^^ variable.other.readwrite -# ^ keyword.operator.assignment +# ^ punctuation.separator.key-value # ^^ meta.mapping.value constant.language foo = yes #^^^^^^^^^^^^ meta.mapping # ^^^ variable.other.readwrite -# ^ keyword.operator.assignment +# ^ punctuation.separator.key-value # ^^^ meta.mapping.value constant.language # ILLEGAL NEWLINE IN SECTION TEST @@ -468,8 +468,8 @@ stray-bracket] #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.mapping # ^^^^^^^^^^^^^ variable.other.readwrite # ^ -variable.other.readwrite -# ^ keyword.operator.assignment -# ^ -keyword.operator.assignment +# ^ punctuation.separator.key-value +# ^ -punctuation.separator.key-value # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.mapping.value # ^^^^^^^^^^^^ string.unquoted.value @@ -478,8 +478,8 @@ stray-bracket] #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.mapping # ^^^^^ variable.other.readwrite # ^ -variable.other.readwrite -# ^ keyword.operator.assignment -# ^ -keyword.operator.assignment +# ^ punctuation.separator.key-value +# ^ -punctuation.separator.key-value # ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.mapping.value # ^^^^^ string.unquoted.value # ^^^^^ string.unquoted.value @@ -490,8 +490,8 @@ stray-bracket] #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.mapping # ^^^^^ variable.other.readwrite # ^ -variable.other.readwrite -# ^ keyword.operator.assignment -# ^ -keyword.operator.assignment +# ^ punctuation.separator.key-value +# ^ -punctuation.separator.key-value # ^^^^^^^^^^^^^^^^^^^ meta.mapping.value # ^^^ string.unquoted.value # ^^ string.unquoted.value @@ -504,8 +504,8 @@ stray-bracket] #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.mapping # ^^^^^ variable.other.readwrite # ^ -variable.other.readwrite -# ^ keyword.operator.assignment -# ^ -keyword.operator.assignment +# ^ punctuation.separator.key-value +# ^ -punctuation.separator.key-value # ^^^^^^^^^^^^^^^^^^^^^^^ meta.mapping.value # ^^^^ string.unquoted.value # ^^^^^^^^^^^^^^^^^^ string.unquoted.value @@ -515,8 +515,8 @@ stray-bracket] #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.mapping # ^^^ variable.other.readwrite # ^ -variable.other.readwrite -# ^ keyword.operator.assignment -# ^ -keyword.operator.assignment +# ^ punctuation.separator.key-value +# ^ -punctuation.separator.key-value # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.mapping.value # ^^^ string.unquoted.value # ^^^^^^^^^ @@ -531,7 +531,7 @@ stray-bracket] # ^^^ meta.mapping # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.mapping.value # ^^^^^ variable.other.readwrite -# ^ keyword.operator.assignment +# ^ punctuation.separator.key-value # ^ keyword.control.import.shell # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.shell serve = "!git daemon --reuseaddr --verbose --base-path=. --export-all ./.git" @@ -541,7 +541,7 @@ stray-bracket] # ^^^ meta.mapping # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.mapping.value # ^^^^^ variable.other.readwrite -# ^ keyword.operator.assignment +# ^ punctuation.separator.key-value # ^ string.quoted.double punctuation.definition.string.begin # ^ keyword.control.import.shell # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.shell @@ -566,7 +566,7 @@ stray-bracket] # ^^^^^^^^^^^^^^^^^^^^^^^ meta.mapping.value # ^ - meta.mapping # ^^^^^^^^^^^^ variable.other.readwrite -# ^ keyword.operator.assignment +# ^ punctuation.separator.key-value # ^ string.quoted.double punctuation.definition.string.begin # ^ keyword.control.import.shell # ^ - source.shell @@ -579,7 +579,7 @@ stray-bracket] # ^^^^^^^^^^^^^^^^^^^^^^^ meta.mapping.value # ^ - meta.mapping # ^^^^^^^^^^^^ variable.other.readwrite -# ^ keyword.operator.assignment +# ^ punctuation.separator.key-value # ^ string.quoted.double punctuation.definition.string.begin # ^ keyword.control.import.shell # ^ - source.shell @@ -592,7 +592,7 @@ stray-bracket] # ^^^ meta.mapping - meta.mapping.key - meta.mapping.value # ^^^^^^^^^^^^^^^^^^^^^^^ meta.mapping.value # ^^^^^^^^^^^^ variable.other.readwrite -# ^ keyword.operator.assignment +# ^ punctuation.separator.key-value # ^ string.quoted.double punctuation.definition.string.begin # ^ keyword.control.import.shell # ^ - source.shell @@ -607,7 +607,7 @@ stray-bracket] # ^^^ meta.mapping - meta.mapping.key - meta.mapping.value # ^^^^^^^^^^^^^^^^^^^^^^^^^ meta.mapping.value # ^^^^^^^^^^^^ variable.other.readwrite -# ^ keyword.operator.assignment +# ^ punctuation.separator.key-value # ^ string.quoted.double punctuation.definition.string.begin # ^ keyword.control.import.shell # ^ - source.shell @@ -620,7 +620,7 @@ stray-bracket] # ^^^ meta.mapping - meta.mapping.key - meta.mapping.value # ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.mapping.value # ^^^^^^^^^^^^ variable.other.readwrite -# ^ keyword.operator.assignment +# ^ punctuation.separator.key-value # ^ string.quoted.double punctuation.definition.string.begin # ^ keyword.control.import.shell # ^ - source.shell @@ -634,7 +634,7 @@ stray-bracket] # ^^^ meta.mapping - meta.mapping.key - meta.mapping.value # ^^^^^^^^^^^^^^^^^^^^^^^^^ meta.mapping.value # ^^^^^^^^^^^^ variable.other.readwrite -# ^ keyword.operator.assignment +# ^ punctuation.separator.key-value # ^ string.quoted.double punctuation.definition.string.begin # ^ keyword.control.import.shell # ^ - source.shell @@ -653,7 +653,7 @@ stray-bracket] # ^^^ meta.mapping - meta.mapping.key - meta.mapping.value # ^^^^^^^^^^^^^^^^^^^^^^^^ meta.mapping.value # ^^^^^^^^^^^^ variable.other.readwrite -# ^ keyword.operator.assignment +# ^ punctuation.separator.key-value # ^ string.quoted.double punctuation.definition.string.begin # ^ keyword.control.import.shell # ^ - source.shell From 3be2e442d359ad86c389883cec8d76e806d82c27 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Fri, 17 Jun 2022 16:11:22 +0200 Subject: [PATCH 16/22] [HTML] Fix slot name attribute completion (#3431) Fixes #3430 --- HTML/html_completions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HTML/html_completions.py b/HTML/html_completions.py index cd041d0c54f..5cc6af60d4c 100644 --- a/HTML/html_completions.py +++ b/HTML/html_completions.py @@ -130,7 +130,7 @@ def get_tag_completions(inside_tag=True): ('param', 'param name=\"$1\" value=\"$2\">'), ('progress', 'progress value=\"$1\" max=\"$2\">'), ('script', 'script${2: type=\"${1:text/javascript}\"}>$0'), - ('slot', 'slot name=name=\"$1\">$0'), + ('slot', 'slot name=\"$1\">$0'), ('source', 'source src=\"$1\" type=\"$2\">'), ('style', 'style type=\"${1:text/css}\">$0'), ('track', 'track kind=\"$1\" src=\"$2\">'), From 43d77b2b8ed4c946a7188ae0775a510034e6c29e Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sat, 18 Jun 2022 22:54:18 +0200 Subject: [PATCH 17/22] [JavaScript] Refactor literal strings (#3432) This commit adds named contexts for literal strings and templates to better support inheritance. It doesn't change behavior. --- JavaScript/JavaScript.sublime-syntax | 99 ++++++++++++++++------------ 1 file changed, 58 insertions(+), 41 deletions(-) diff --git a/JavaScript/JavaScript.sublime-syntax b/JavaScript/JavaScript.sublime-syntax index 13c78d36090..423dbf6410c 100644 --- a/JavaScript/JavaScript.sublime-syntax +++ b/JavaScript/JavaScript.sublime-syntax @@ -1088,52 +1088,54 @@ contexts: - include: else-pop literal-string: - - match: "'" + - include: literal-double-quoted-string + - include: literal-single-quoted-string + + literal-double-quoted-string: + - match: \" scope: punctuation.definition.string.begin.js - set: - - meta_include_prototype: false - - meta_scope: meta.string.js string.quoted.single.js - - match: \' - scope: punctuation.definition.string.end.js - pop: true - - match: \n - scope: invalid.illegal.newline.js - pop: true - - include: string-content - - match: '"' + set: literal-double-quoted-string-content + + literal-double-quoted-string-content: + - meta_include_prototype: false + - meta_scope: meta.string.js string.quoted.double.js + - match: \" + scope: punctuation.definition.string.end.js + pop: true + - match: \n + scope: invalid.illegal.newline.js + pop: true + - include: string-content + + literal-single-quoted-string: + - match: \' scope: punctuation.definition.string.begin.js - set: - - meta_include_prototype: false - - meta_scope: meta.string.js string.quoted.double.js - - match: \" - scope: punctuation.definition.string.end.js - pop: true - - match: \n - scope: invalid.illegal.newline.js - pop: true - - include: string-content + set: literal-single-quoted-string-content + + literal-single-quoted-string-content: + - meta_include_prototype: false + - meta_scope: meta.string.js string.quoted.single.js + - match: \' + scope: punctuation.definition.string.end.js + pop: true + - match: \n + scope: invalid.illegal.newline.js + pop: true + - include: string-content literal-string-template: - - match: '`' + - match: \` scope: punctuation.definition.string.begin.js - set: - - meta_include_prototype: false - - meta_scope: meta.string.js string.quoted.other.js - - match: "`" - scope: punctuation.definition.string.end.js - pop: true - - match: '\$\{' - scope: punctuation.section.interpolation.begin.js - push: - - clear_scopes: 1 - - meta_scope: meta.interpolation.js - - meta_content_scope: source.js.embedded - - match: '\}' - scope: punctuation.section.interpolation.end.js - pop: true - - match: (?=\S) - push: expression - - include: string-content + set: literal-string-template-content + + literal-string-template-content: + - meta_include_prototype: false + - meta_scope: meta.string.js string.quoted.other.js + - match: \` + scope: punctuation.definition.string.end.js + pop: true + - include: string-interpolations + - include: string-content string-content: - match: \\\n @@ -1141,6 +1143,21 @@ contexts: - match: \\(?:x\h\h|u\h\h\h\h|.) scope: constant.character.escape.js + string-interpolations: + - match: \$\{ + scope: punctuation.section.interpolation.begin.js + push: string-interpolation-content + + string-interpolation-content: + - clear_scopes: 1 + - meta_scope: meta.interpolation.js + - meta_content_scope: source.js.embedded + - match: \} + scope: punctuation.section.interpolation.end.js + pop: true + - match: (?=\S) + push: expression + regexp-complete: - match: '/' scope: punctuation.definition.string.begin.js From 5228b6accc6a1fe3903e328fe4d727a0221bf245 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sun, 19 Jun 2022 09:52:06 +0200 Subject: [PATCH 18/22] [JavaScript] Replace pop: true by pop: 1 (#3434) JavaScript uses sublime-syntax `version: 2` and makes use of `pop: 2` in 2 contexts. Thus it might be consistent to use explicit `pop: 1` instead of legacy `pop: true`. This commit doesn't change behavior. --- JavaScript/JSX.sublime-syntax | 14 +- JavaScript/JavaScript.sublime-syntax | 326 +++++++++--------- ...ar Expressions (JavaScript).sublime-syntax | 6 +- JavaScript/TSX.sublime-syntax | 4 +- JavaScript/TypeScript.sublime-syntax | 96 +++--- 5 files changed, 223 insertions(+), 223 deletions(-) diff --git a/JavaScript/JSX.sublime-syntax b/JavaScript/JSX.sublime-syntax index 80e4a316d35..8900616db95 100644 --- a/JavaScript/JSX.sublime-syntax +++ b/JavaScript/JSX.sublime-syntax @@ -45,7 +45,7 @@ contexts: captures: 1: punctuation.definition.comment.end.js 2: punctuation.definition.interpolation.end.js - pop: true + pop: 1 - match: (?=\*/) fail: jsx-interpolation-comment @@ -57,14 +57,14 @@ contexts: - meta_content_scope: source.js.embedded.jsx - match: '}' scope: punctuation.definition.interpolation.end.js - pop: true + pop: 1 - expression jsx-expect-tag-end: - meta_content_scope: meta.tag.js - match: '>' scope: meta.tag.js punctuation.definition.tag.end.js - pop: true + pop: 1 - include: else-pop jsx-meta: @@ -132,7 +132,7 @@ contexts: - meta_scope: string.quoted.single.js - match: \' scope: punctuation.definition.string.end.js - pop: true + pop: 1 - include: jsx-html-escapes - match: '"' scope: punctuation.definition.string.begin.js @@ -141,7 +141,7 @@ contexts: - meta_scope: string.quoted.double.js - match: \" scope: punctuation.definition.string.end.js - pop: true + pop: 1 - include: jsx-html-escapes - include: else-pop @@ -176,13 +176,13 @@ contexts: jsx-tag-name-component: - match: '{{jsx_identifier}}' scope: entity.name.tag.js - pop: true + pop: 1 - include: else-pop jsx-tag-name-component-possibly-native: - match: '[[:lower:]]{{jsx_identifier_part}}*{{jsx_identifier_break}}(?!{{nothing}}[.:])' scope: entity.name.tag.native.js - pop: true + pop: 1 - include: jsx-tag-name-component jsx-body: diff --git a/JavaScript/JavaScript.sublime-syntax b/JavaScript/JavaScript.sublime-syntax index 423dbf6410c..057dc164870 100644 --- a/JavaScript/JavaScript.sublime-syntax +++ b/JavaScript/JavaScript.sublime-syntax @@ -154,7 +154,7 @@ contexts: block-comment-end: - match: \*+/ scope: punctuation.definition.comment.end.js - pop: true + pop: 1 block-comment-body: - meta_include_prototype: false @@ -230,11 +230,11 @@ contexts: else-pop: - match: (?=\S) - pop: true + pop: 1 immediately-pop: - match: '' - pop: true + pop: 1 immediately-pop-2: - meta_include_prototype: false @@ -285,10 +285,10 @@ contexts: set: - match: default{{identifier_break}} scope: keyword.control.import-export.js - pop: true + pop: 1 - match: '{{identifier_name}}' scope: variable.other.readwrite.js - pop: true + pop: 1 - include: else-pop - include: else-pop @@ -321,10 +321,10 @@ contexts: set: import-brace - match: '{{non_reserved_identifier}}' scope: variable.other.readwrite.js - pop: true + pop: 1 - match: '\*' scope: constant.other.js - pop: true + pop: 1 - include: else-pop import-brace: @@ -332,7 +332,7 @@ contexts: - include: comma-separator - match: '\}' scope: punctuation.section.block.end.js - pop: true + pop: 1 - match: '{{identifier_name}}' scope: variable.other.readwrite.js push: import-export-alias @@ -386,10 +386,10 @@ contexts: set: export-brace - match: '{{non_reserved_identifier}}' scope: variable.other.readwrite.js - pop: true + pop: 1 - match: '\*' scope: constant.other.js - pop: true + pop: 1 - include: else-pop export-brace: @@ -397,7 +397,7 @@ contexts: - include: comma-separator - match: '\}' scope: punctuation.section.block.end.js - pop: true + pop: 1 - match: '{{identifier_name}}' scope: variable.other.readwrite.js push: import-export-alias @@ -409,7 +409,7 @@ contexts: statements: - match: '\)|\}|\]' scope: invalid.illegal.stray-bracket-end.js - pop: true + pop: 1 - match: (?=\S) push: statement @@ -417,7 +417,7 @@ contexts: statement: - match: \; scope: punctuation.terminator.statement.empty.js - pop: true + pop: 1 - include: declaration - include: import-statement-or-import-meta @@ -462,7 +462,7 @@ contexts: expect-semicolon: - match: \; scope: punctuation.terminator.statement.js - pop: true + pop: 1 - include: else-pop expect-label: @@ -471,10 +471,10 @@ contexts: set: - match: '{{non_reserved_identifier}}' scope: variable.label.js - pop: true + pop: 1 - match: '{{identifier_name}}' scope: invalid.illegal.identifier.js variable.label.js - pop: true + pop: 1 - include: else-pop - include: immediately-pop @@ -485,7 +485,7 @@ contexts: - meta_scope: meta.block.js - match: '\}' scope: punctuation.section.block.end.js - pop: true + pop: 1 - include: statements variable-binding-pattern: @@ -508,7 +508,7 @@ contexts: - meta_scope: meta.binding.destructuring.sequence.js - match: '\]' scope: punctuation.section.sequence.end.js - pop: true + pop: 1 - include: variable-binding-spread - include: variable-binding-list @@ -519,7 +519,7 @@ contexts: - meta_scope: meta.binding.destructuring.mapping.js - match: '\}' scope: punctuation.section.mapping.end.js - pop: true + pop: 1 - include: variable-binding-spread - match: (?={{identifier_start}}|\[|'|") push: @@ -537,7 +537,7 @@ contexts: variable-binding-object-key: - match: '{{identifier_name}}(?=\s*:)' - pop: true + pop: 1 - include: literal-string - include: computed-property-name - include: variable-binding-name @@ -605,7 +605,7 @@ contexts: - meta_scope: meta.binding.destructuring.sequence.js - match: '\]' scope: punctuation.section.sequence.end.js - pop: true + pop: 1 - include: function-parameter-binding-list function-parameter-binding-object-destructuring: @@ -617,7 +617,7 @@ contexts: scope: punctuation.separator.parameter.function.js - match: '\}' scope: punctuation.section.mapping.end.js - pop: true + pop: 1 - include: function-parameter-binding-spread - match: (?={{identifier_start}}|\[|'|") push: @@ -634,7 +634,7 @@ contexts: function-parameter-binding-object-key: - match: '{{identifier_name}}(?=\s*:)' - pop: true + pop: 1 - include: literal-string - include: computed-property-name - include: function-parameter-binding-name @@ -683,14 +683,14 @@ contexts: restricted-production: - meta_include_prototype: false - match: '{{line_ending_ahead}}' - pop: true + pop: 1 - match: '' set: expression-statement expect-case-colon: - match: ':' scope: punctuation.separator.js - pop: true + pop: 1 - include: else-pop conditional: @@ -821,7 +821,7 @@ contexts: for-await: - match: await{{identifier_break}} scope: keyword.control.flow.await.js - pop: true + pop: 1 - include: else-pop for-condition: @@ -837,7 +837,7 @@ contexts: - match: '\)' scope: punctuation.section.group.end.js - pop: true + pop: 1 for-condition-contents: # This could be either type of for loop. @@ -867,7 +867,7 @@ contexts: for-oldstyle-rest: - match: (?=\)) - pop: true + pop: 1 - match: ; scope: punctuation.separator.expression.js - match: (?=\S) @@ -893,7 +893,7 @@ contexts: - match: '\}' scope: punctuation.section.block.end.js - pop: true + pop: 1 - match: case{{identifier_break}} scope: keyword.control.conditional.case.js @@ -930,7 +930,7 @@ contexts: decorator-name: - match: '{{identifier_name}}(?!\s*[.\(`])' scope: variable.annotation.js - pop: true + pop: 1 decorator-expression-end: - match: '{{dot_accessor}}' @@ -955,7 +955,7 @@ contexts: expression-break: - match: (?=[;})\]]) - pop: true + pop: 1 expression: - meta_include_prototype: false @@ -995,12 +995,12 @@ contexts: expression-end-no-comma: - match: (?=,) - pop: true + pop: 1 - include: expression-end expression-end-no-in: - match: (?=in{{identifier_break}}) - pop: true + pop: 1 - include: expression-end expression-begin: @@ -1023,7 +1023,7 @@ contexts: - include: regular-function - match: (?={{reserved_word}}) - pop: true + pop: 1 - match: (?={{identifier_name}}{{function_assignment_lookahead}}) set: @@ -1034,7 +1034,7 @@ contexts: # Newline not allowed between `async` and parameters. - match: (?=async{{identifier_break}}{{nothing}}{{possible_arrow_function_begin}}) - pop: true + pop: 1 branch_point: async-arrow-function branch: - async-arrow-function @@ -1043,7 +1043,7 @@ contexts: - include: literal-call - match: (?={{possible_arrow_function_begin}}) - pop: true + pop: 1 branch_point: arrow-function branch: - branch-possible-arrow-function @@ -1067,7 +1067,7 @@ contexts: arrow-function-expect-arrow-or-fail-async: - match: '=>' scope: keyword.declaration.function.arrow.js - pop: true + pop: 1 - match: (?=\S) fail: async-arrow-function @@ -1101,10 +1101,10 @@ contexts: - meta_scope: meta.string.js string.quoted.double.js - match: \" scope: punctuation.definition.string.end.js - pop: true + pop: 1 - match: \n scope: invalid.illegal.newline.js - pop: true + pop: 1 - include: string-content literal-single-quoted-string: @@ -1117,10 +1117,10 @@ contexts: - meta_scope: meta.string.js string.quoted.single.js - match: \' scope: punctuation.definition.string.end.js - pop: true + pop: 1 - match: \n scope: invalid.illegal.newline.js - pop: true + pop: 1 - include: string-content literal-string-template: @@ -1133,7 +1133,7 @@ contexts: - meta_scope: meta.string.js string.quoted.other.js - match: \` scope: punctuation.definition.string.end.js - pop: true + pop: 1 - include: string-interpolations - include: string-content @@ -1154,7 +1154,7 @@ contexts: - meta_content_scope: source.js.embedded - match: \} scope: punctuation.section.interpolation.end.js - pop: true + pop: 1 - match: (?=\S) push: expression @@ -1179,7 +1179,7 @@ contexts: push: - meta_include_prototype: false - match: '(?=/)' - pop: true + pop: 1 - include: scope:source.regexp.js constructor: @@ -1214,15 +1214,15 @@ contexts: - include: support - match: '{{dollar_only_identifier}}' scope: variable.type.dollar.only.js punctuation.dollar.js - pop: true + pop: 1 - match: '{{dollar_identifier}}' scope: variable.type.dollar.js captures: 1: punctuation.dollar.js - pop: true + pop: 1 - match: '{{identifier_name}}' scope: variable.type.js - pop: true + pop: 1 - include: else-pop - include: expression-begin @@ -1233,7 +1233,7 @@ contexts: set: - match: target{{identifier_break}} scope: variable.language.target.js - pop: true + pop: 1 - include: else-pop - include: else-pop @@ -1351,7 +1351,7 @@ contexts: scope: keyword.control.flow.yield.js set: - match: $ - pop: true + pop: 1 - match: \* scope: keyword.generator.asterisk.js set: expression-begin @@ -1388,7 +1388,7 @@ contexts: - match: '\}' scope: punctuation.section.block.end.js - pop: true + pop: 1 - match: \; scope: punctuation.terminator.statement.js @@ -1448,12 +1448,12 @@ contexts: - meta_scope: meta.block.js - match: \} scope: punctuation.section.block.end.js - pop: true + pop: 1 - include: statements class-element-modifiers: - match: '' - pop: true + pop: 1 branch_point: class-element-modifier branch: - class-element-modifier @@ -1464,7 +1464,7 @@ contexts: scope: storage.modifier.js set: - match: (?={{class_element_name}}|\*) - pop: true + pop: 1 - match: (?=\S) fail: class-element-modifier @@ -1479,7 +1479,7 @@ contexts: inherited-class-name: - match: '{{non_reserved_identifier}}{{left_expression_end_lookahead}}' scope: entity.other.inherited-class.js - pop: true + pop: 1 inherited-class-expression-end: - match: '{{dot_accessor}}' @@ -1497,12 +1497,12 @@ contexts: class-name: - match: '{{non_reserved_identifier}}' scope: entity.name.class.js - pop: true + pop: 1 - include: else-pop class-element: - match: '' - pop: true + pop: 1 branch_point: class-field branch: - class-field @@ -1559,19 +1559,19 @@ contexts: special-name: - match: true{{identifier_break}} scope: constant.language.boolean.true.js - pop: true + pop: 1 - match: false{{identifier_break}} scope: constant.language.boolean.false.js - pop: true + pop: 1 - match: null{{identifier_break}} scope: constant.language.null.js - pop: true + pop: 1 - match: super{{identifier_break}} scope: variable.language.super.js - pop: true + pop: 1 - match: this{{identifier_break}} scope: variable.language.this.js - pop: true + pop: 1 function-name-meta: - meta_include_prototype: false @@ -1610,25 +1610,25 @@ contexts: function-declaration-expect-name: - match: '{{non_reserved_identifier}}' scope: entity.name.function.js - pop: true + pop: 1 - include: else-pop function-declaration-expect-generator-star: - match: \* scope: keyword.declaration.generator.js - pop: true + pop: 1 - include: else-pop function-declaration-expect-function-keyword: - match: function{{identifier_break}} scope: keyword.declaration.function.js - pop: true + pop: 1 - include: else-pop function-declaration-expect-async: - match: 'async{{identifier_break}}' scope: keyword.declaration.async.js - pop: true + pop: 1 - include: else-pop arrow-function-declaration: @@ -1650,7 +1650,7 @@ contexts: arrow-function-expect-arrow: - match: '=>' scope: keyword.declaration.function.arrow.js - pop: true + pop: 1 - include: else-pop arrow-function-expect-parameters: @@ -1660,7 +1660,7 @@ contexts: - meta_scope: meta.function.parameters.js - match: '{{identifier_name}}' scope: variable.parameter.function.js - pop: true + pop: 1 - include: function-declaration-parameters - include: else-pop @@ -1671,7 +1671,7 @@ contexts: - meta_scope: meta.block.js - match: '\}' scope: punctuation.section.block.end.js - pop: true + pop: 1 - include: statements function-declaration-parameters: @@ -1682,7 +1682,7 @@ contexts: - meta_scope: meta.function.parameters.js - match: \) scope: punctuation.section.group.end.js - pop: true + pop: 1 - include: function-parameter-binding-list label: @@ -1701,7 +1701,7 @@ contexts: - match: '\}' scope: punctuation.section.mapping.end.js - pop: true + pop: 1 - match: \.\.\. scope: keyword.operator.spread.js @@ -1742,9 +1742,9 @@ contexts: object-literal-element: - match: '{{identifier_name}}(?=\s*(?:[},]|$|//|/\*))' scope: variable.other.readwrite.js - pop: true + pop: 1 - match: (?=\S) - pop: true + pop: 1 branch_point: object-literal-property branch: - object-literal-property @@ -1763,7 +1763,7 @@ contexts: - include: literal-number - match: '{{identifier_name}}' - pop: true + pop: 1 - include: else-pop @@ -1779,7 +1779,7 @@ contexts: - meta_scope: meta.brackets.js - match: \] scope: punctuation.section.brackets.end.js - pop: true + pop: 1 - match: (?=\S) push: expression @@ -1792,15 +1792,15 @@ contexts: scope: meta.mapping.key.dollar.js entity.name.function.js captures: 1: punctuation.dollar.js - pop: true + pop: 1 - match: '{{identifier_name}}' scope: entity.name.function.js - pop: true + pop: 1 - match: '(#){{identifier_name}}' scope: entity.name.function.js captures: 1: punctuation.definition.js - pop: true + pop: 1 - match: "'" scope: punctuation.definition.string.begin.js set: @@ -1809,10 +1809,10 @@ contexts: - meta_content_scope: entity.name.function.js - match: \' scope: punctuation.definition.string.end.js - pop: true + pop: 1 - match: \n scope: invalid.illegal.newline.js - pop: true + pop: 1 - include: string-content - match: '"' scope: punctuation.definition.string.begin.js @@ -1822,10 +1822,10 @@ contexts: - meta_content_scope: entity.name.function.js - match: \" scope: punctuation.definition.string.end.js - pop: true + pop: 1 - match: \n scope: invalid.illegal.newline.js - pop: true + pop: 1 - include: string-content - include: computed-property-name @@ -1837,15 +1837,15 @@ contexts: scope: meta.mapping.key.dollar.js variable.other.readwrite.js captures: 1: punctuation.dollar.js - pop: true + pop: 1 - match: '{{identifier_name}}' scope: variable.other.readwrite.js - pop: true + pop: 1 - match: (#)({{identifier_name}}) captures: 1: punctuation.definition.variable.js 2: variable.other.readwrite.js - pop: true + pop: 1 - match: "'" scope: punctuation.definition.string.begin.js set: @@ -1854,10 +1854,10 @@ contexts: - meta_content_scope: variable.other.readwrite.js - match: \' scope: punctuation.definition.string.end.js - pop: true + pop: 1 - match: \n scope: invalid.illegal.newline.js - pop: true + pop: 1 - include: string-content - match: '"' scope: punctuation.definition.string.begin.js @@ -1867,10 +1867,10 @@ contexts: - meta_content_scope: variable.other.readwrite.js - match: \" scope: punctuation.definition.string.end.js - pop: true + pop: 1 - match: \n scope: invalid.illegal.newline.js - pop: true + pop: 1 - include: string-content - include: computed-property-name @@ -1899,7 +1899,7 @@ contexts: - meta_scope: meta.group.js - match: \) scope: punctuation.section.group.end.js - pop: true + pop: 1 - match: (?=\S) push: expression @@ -1912,7 +1912,7 @@ contexts: - meta_scope: meta.group.js - match: \) scope: punctuation.section.group.end.js - pop: true + pop: 1 - include: expression-list array-literal: @@ -1922,7 +1922,7 @@ contexts: - meta_scope: meta.sequence.js - match: '\]' scope: punctuation.section.sequence.end.js - pop: true + pop: 1 - include: expression-list property-access: @@ -1934,7 +1934,7 @@ contexts: - meta_scope: meta.brackets.js - match: '\]' scope: punctuation.section.brackets.end.js - pop: true + pop: 1 - match: (?=\S) push: expression @@ -1962,7 +1962,7 @@ contexts: captures: 1: punctuation.separator.decimal.js 2: punctuation.separator.decimal.js - pop: true + pop: 1 # integers - match: (0)({{dec_digit}}+){{identifier_break}} @@ -1970,7 +1970,7 @@ contexts: captures: 1: constant.numeric.base.js invalid.deprecated.numeric.octal.js 2: constant.numeric.value.js invalid.deprecated.numeric.octal.js - pop: true + pop: 1 - match: (0[Xx])({{hex_digit}}*)(n)?{{identifier_break}} scope: meta.number.integer.hexadecimal.js @@ -1978,7 +1978,7 @@ contexts: 1: constant.numeric.base.js 2: constant.numeric.value.js 3: constant.numeric.suffix.js - pop: true + pop: 1 - match: (0[Oo])({{oct_digit}}*)(n)?{{identifier_break}} scope: meta.number.integer.octal.js @@ -1986,7 +1986,7 @@ contexts: 1: constant.numeric.base.js 2: constant.numeric.value.js 3: constant.numeric.suffix.js - pop: true + pop: 1 - match: (0[Bb])({{bin_digit}}*)(n)?{{identifier_break}} scope: meta.number.integer.binary.js @@ -1994,31 +1994,31 @@ contexts: 1: constant.numeric.base.js 2: constant.numeric.value.js 3: constant.numeric.suffix.js - pop: true + pop: 1 - match: ({{dec_integer}})(n|(?!\.)){{identifier_break}} scope: meta.number.integer.decimal.js captures: 1: constant.numeric.value.js 2: constant.numeric.suffix.js - pop: true + pop: 1 # illegal numbers - match: 0[Xx]{{identifier_part}}+ scope: invalid.illegal.numeric.hexadecimal.js - pop: true + pop: 1 - match: 0[Bb]{{identifier_part}}+ scope: invalid.illegal.numeric.binary.js - pop: true + pop: 1 - match: 0{{identifier_part}}+ scope: invalid.illegal.numeric.octal.js - pop: true + pop: 1 - match: '[1-9]{{identifier_part}}+(?:\.{{identifier_part}}*)?' scope: invalid.illegal.numeric.decimal.js - pop: true + pop: 1 literal-call: - match: (?={{identifier_name}}\s*(?:{{dot_accessor}})?\() @@ -2053,22 +2053,22 @@ contexts: call-function-name: - match: '{{dollar_only_identifier}}' scope: variable.function.js variable.other.dollar.only.js punctuation.dollar.js - pop: true + pop: 1 - match: '{{identifier_name}}' scope: variable.function.js - pop: true + pop: 1 - include: else-pop call-method-name: - include: support-property - match: '{{identifier_name}}' scope: variable.function.js - pop: true + pop: 1 - match: '(#){{identifier_name}}' scope: variable.function.js captures: 1: punctuation.definition.js - pop: true + pop: 1 - include: else-pop literal-variable: @@ -2082,11 +2082,11 @@ contexts: - match: '{{identifier_name}}(?={{nothing}}`)' scope: variable.function.tagged-template.js - pop: true + pop: 1 - match: '{{constant_identifier}}(?=\s*(?:{{dot_accessor}}|\[))' scope: support.class.js - pop: true + pop: 1 - match: '{{function_call_lookahead}}' set: call-function-name @@ -2096,18 +2096,18 @@ contexts: literal-variable-base: - match: '{{dollar_only_identifier}}' scope: variable.other.dollar.only.js punctuation.dollar.js - pop: true + pop: 1 - match: '{{dollar_identifier}}' scope: variable.other.dollar.js captures: 1: punctuation.dollar.js - pop: true + pop: 1 - match: '{{constant_identifier}}' scope: variable.other.constant.js - pop: true + pop: 1 - match: '{{identifier_name}}' scope: variable.other.readwrite.js - pop: true + pop: 1 - include: literal-private-variable literal-private-variable: @@ -2115,25 +2115,25 @@ contexts: captures: 1: punctuation.definition.variable.js 2: variable.other.readwrite.js - pop: true + pop: 1 special-identifier: # These are ordinary identifiers, not reserved words - match: arguments{{identifier_break}} scope: variable.language.arguments.js - pop: true + pop: 1 - match: globalThis{{identifier_break}} scope: variable.language.global.js - pop: true + pop: 1 - match: undefined{{identifier_break}} scope: constant.language.undefined.js - pop: true + pop: 1 - match: NaN{{identifier_break}} scope: constant.language.nan.js - pop: true + pop: 1 - match: Infinity{{identifier_break}} scope: constant.language.infinity.js - pop: true + pop: 1 support: - include: support-variable-ecma @@ -2320,98 +2320,98 @@ contexts: # Classes with no constructor properties - match: (?:Boolean|DataView|Function|Map|RegExp|Set|WeakMap|WeakSet){{identifier_break}} scope: support.class.builtin.js - pop: true + pop: 1 - match: (?:Eval|Range|Reference|Syntax|Type|URI)?Error{{identifier_break}} scope: support.class.builtin.js - pop: true + pop: 1 - match: (?:eval|isFinite|isNaN|parseFloat|parseInt|decodeURI|decodeURIComponent|encodeURI|encodeURIComponent){{identifier_break}} scope: support.function.js - pop: true + pop: 1 support-property-ecma-array: - match: (?:from|isArray|of){{identifier_break}} scope: support.function.builtin.js - pop: true + pop: 1 support-property-ecma-arraybuffer: - match: isView{{identifier_break}} scope: support.function.builtin.js - pop: true + pop: 1 support-property-ecma-atomics: - match: (?:and|add|compareExchange|exchange|isLockFree|load|or|store|sub|wait|wake|xor){{identifier_break}} scope: support.function.builtin.js - pop: true + pop: 1 support-property-ecma-bigint: - match: (?:asUintN|asIntN){{identifier_break}} scope: support.function.builtin.js - pop: true + pop: 1 support-property-ecma-date: - match: (?:now|parse|UTC){{identifier_break}} scope: support.function.builtin.js - pop: true + pop: 1 support-property-ecma-json: - match: (?:parse|stringify){{identifier_break}} scope: support.function.builtin.js - pop: true + pop: 1 support-property-ecma-math: - match: (?:E|LN10|LN2|LOG10E|LOG2E|PI|SQRT1_2|SQRT2){{identifier_break}} scope: support.constant.builtin.js - pop: true + pop: 1 - match: (?:abs|acos|acosh|asin|asin|atan|atanh|atan2|cbrt|ceil|clz32|cos|cosh|exp|expm1|floor|fround|hypot|imul|log|log1p|log10|log2|max|min|pow|random|round|sign|sin|sinh|sqrt|tan|tanh|trunc){{identifier_break}} scope: support.function.builtin.js - pop: true + pop: 1 support-property-ecma-number: - match: (?:EPSILON|MAX_SAFE_INTEGER|MAX_VALUE|MIN_SAFE_INTEGER|MIN_VALUE|NEGATIVE_INFINITY|POSITIVE_INFINITY){{identifier_break}} scope: support.constant.builtin.js - pop: true + pop: 1 - match: (?:isFinite|isInteger|isNaN|isSafeInteger|NaN|parseFloat|parseInt){{identifier_break}} scope: support.function.builtin.js - pop: true + pop: 1 support-property-ecma-object: - match: (?:assign|create|defineProperties|defineProperty|entries|freeze|fromEntries|getOwnPropertyDescriptors?|getOwnPropertyNames|getOwnPropertySymbols|getPrototypeOf|is|isExtensible|isFrozen|isSealed|keys|preventExtensions|seal|setPrototypeOf|values){{identifier_break}} scope: support.function.builtin.js - pop: true + pop: 1 support-property-ecma-promise: - match: (?:all|race|reject|resolve|allSettled|any){{identifier_break}} scope: support.function.builtin.js - pop: true + pop: 1 support-property-ecma-proxy: - match: revocable{{identifier_break}} scope: support.function.builtin.js - pop: true + pop: 1 support-property-ecma-reflect: - match: (?:apply|construct|defineProperty|deleteProperty|get|getOwnPropertyDescriptor|getPrototypeOf|has|isExtensible|ownKeys|preventExtensions|set|setPrototypeOf){{identifier_break}} scope: support.function.builtin.js - pop: true + pop: 1 support-property-ecma-string: - match: (?:fromCharCode|fromCodePoint|raw){{identifier_break}} scope: support.function.builtin.js - pop: true + pop: 1 support-property-ecma-symbol: - match: (?:asyncIterator|hasInstance|isConcatSpreadable|iterator|match|replace|search|species|split|toPrimitive|toStringTag|unscopeables){{identifier_break}} scope: support.constant.builtin.js - pop: true + pop: 1 - match: (?:for|keyFor){{identifier_break}} scope: support.function.builtin.js - pop: true + pop: 1 support-property-ecma-typedarray: - match: (?:BYTES_PER_ELEMENT){{identifier_break}} scope: support.constant.builtin.js - pop: true + pop: 1 support-variable-console: # https://console.spec.whatwg.org/ @@ -2426,22 +2426,22 @@ contexts: support-variable-dom: - match: XMLHttpRequest{{identifier_break}} scope: support.class.dom.js - pop: true + pop: 1 - match: (?:document|window|navigator){{identifier_break}} scope: support.type.object.dom.js - pop: true + pop: 1 - match: (?:clearTimeout|clearInterval|setTimeout|setInterval){{identifier_break}} scope: support.function.dom.js - pop: true + pop: 1 support-variable-node: - match: global{{identifier_break}} scope: support.type.object.node.js - pop: true + pop: 1 - match: Buffer{{identifier_break}} scope: support.class.node.js - pop: true + pop: 1 - match: process{{identifier_break}} scope: support.constant.node.js @@ -2457,7 +2457,7 @@ contexts: # Module-level variables - match: (?:__dirname|__filename|exports){{identifier_break}} scope: support.constant.node.js - pop: true + pop: 1 - match: module{{identifier_break}} scope: support.constant.node.js set: @@ -2470,28 +2470,28 @@ contexts: - include: else-pop - match: require{{identifier_break}} scope: support.function.node.js - pop: true + pop: 1 support-property-node-process: - match: (?:arch|argv|argv0|channel|config|connected|debugPort|env|execArgv|execPath|exitCode|mainModule|noDeprecation|pid|platform|ppid|release|stderr|stdin|stdout|throwDeprecation|title|traceDeprecation|version|versions){{identifier_break}} scope: support.constant.node.js - pop: true + pop: 1 - match: (?:abort|chdir|cpuUsage|cwd|disconnect|dlopen|emitWarning|exit|getegid|geteuid|getgit|getgroups|getuid|hasUncaughtExceptionCaptureCallback|hrtime|initGroups|kill|memoryUsage|nextTick|send|setegid|seteuid|setgid|setgroups|setuid|hasUncaughtExceptionCaptureCallback|umask|uptime){{identifier_break}} scope: support.function.node.js - pop: true + pop: 1 support-property-node-module: - match: (?:children|exports|filename|id|loaded|parent|paths){{identifier_break}} scope: support.constant.node.js - pop: true + pop: 1 - match: require{{identifier_break}} scope: support.function.node.js - pop: true + pop: 1 builtin-console-properties: - match: (?:warn|info|log|error|time|timeEnd|assert|count|dir|group|groupCollapsed|groupEnd|profile|profileEnd|table|trace|timeStamp){{identifier_break}} scope: support.function.console.js - pop: true + pop: 1 - include: object-property object-property: @@ -2507,7 +2507,7 @@ contexts: - match: '{{identifier_name}}(?={{nothing}}`)' scope: variable.function.tagged-template.js - pop: true + pop: 1 - include: object-property-base - include: else-pop @@ -2515,23 +2515,23 @@ contexts: object-property-base: - match: '{{dollar_only_identifier}}' scope: meta.property.object.dollar.only.js punctuation.dollar.js - pop: true + pop: 1 - match: '{{dollar_identifier}}' scope: meta.property.object.dollar.js captures: 1: punctuation.dollar.js - pop: true + pop: 1 - match: '{{identifier_name}}' scope: meta.property.object.js - pop: true + pop: 1 - match: '{{identifier_part}}+{{identifier_break}}' scope: invalid.illegal.illegal-identifier.js - pop: true + pop: 1 - match: (#)({{identifier_name}}) captures: 1: punctuation.definition.variable.js 2: meta.property.object.js - pop: true + pop: 1 support-property: - include: support-property-ecma @@ -2539,22 +2539,22 @@ contexts: support-property-ecma: - match: constructor{{identifier_break}} scope: variable.language.constructor.js - pop: true + pop: 1 - match: prototype{{identifier_break}} scope: support.constant.prototype.js - pop: true + pop: 1 - match: (?:hasOwnProperty|isPrototypeOf|propertyIsEnumerable|toLocaleString|toString|valueOf){{identifier_break}} scope: support.function.js - pop: true + pop: 1 # Annex B - match: __proto__{{identifier_break}} scope: invalid.deprecated.js variable.language.prototype.js - pop: true + pop: 1 - match: (?:__defineGetter__|__defineSetter__|__lookupGetter__){{identifier_break}} scope: invalid.deprecated.js support.function.js - pop: true + pop: 1 import-meta-expression: - match: import{{identifier_break}} @@ -2569,6 +2569,6 @@ contexts: set: - match: meta{{identifier_break}} scope: variable.language.import.js - pop: true + pop: 1 - include: object-property - include: else-pop diff --git a/JavaScript/Regular Expressions (JavaScript).sublime-syntax b/JavaScript/Regular Expressions (JavaScript).sublime-syntax index b6d5ccb602f..3f0532d2211 100644 --- a/JavaScript/Regular Expressions (JavaScript).sublime-syntax +++ b/JavaScript/Regular Expressions (JavaScript).sublime-syntax @@ -54,7 +54,7 @@ contexts: - meta_scope: constant.other.character-class.set.regexp - match: '\]' scope: punctuation.definition.character-class.end.regexp - pop: true + pop: 1 - match: |- (?x) (?: @@ -90,7 +90,7 @@ contexts: - meta_scope: meta.group.assertion.regexp - match: \) scope: punctuation.definition.group.end.regexp - pop: true + pop: 1 - include: main group-definition: @@ -106,7 +106,7 @@ contexts: - meta_scope: meta.group.regexp - match: \) scope: punctuation.definition.group.end.regexp - pop: true + pop: 1 - include: main operator: diff --git a/JavaScript/TSX.sublime-syntax b/JavaScript/TSX.sublime-syntax index 15962347b61..7ac1ee55b0a 100644 --- a/JavaScript/TSX.sublime-syntax +++ b/JavaScript/TSX.sublime-syntax @@ -58,11 +58,11 @@ contexts: scope: entity.other.attribute-name.js set: - match: (?=[>=]) - pop: true + pop: 1 - match: (?=\S) fail: arrow-function - match: (?=[/>{]|{{identifier_start}}) - pop: true + pop: 1 - match: (?=\S) fail: arrow-function diff --git a/JavaScript/TypeScript.sublime-syntax b/JavaScript/TypeScript.sublime-syntax index 907aac48095..d24c8ad92b5 100644 --- a/JavaScript/TypeScript.sublime-syntax +++ b/JavaScript/TypeScript.sublime-syntax @@ -105,7 +105,7 @@ contexts: ts-detect-parenthesized-arrow-return-type: - match: (?=:) - pop: true + pop: 1 branch_point: ts-arrow-function-return-type branch: - ts-detect-arrow-function-return-type @@ -228,7 +228,7 @@ contexts: - literal-string - include: declaration - match: (?={{identifier_start}}) - pop: true + pop: 1 - match: (?=\S) fail: ts-declare @@ -253,21 +253,21 @@ contexts: - include: ts-namespace-declaration - match: (?=const{{identifier_break}}) - pop: true + pop: 1 branch_point: ts-const-enum branch: - ts-const-declaration - ts-const-enum - match: (?=declare{{identifier_break}}) - pop: true + pop: 1 branch_point: ts-declare branch: - ts-declare - expression-statement - match: (?=abstract{{identifier_break}}) - pop: true + pop: 1 branch_point: ts-abstract-class branch: - ts-abstract-class @@ -336,7 +336,7 @@ contexts: ts-interface-name: - match: '{{identifier_name}}' scope: entity.name.interface.js - pop: true + pop: 1 - include: else-pop ts-interface-body: @@ -346,7 +346,7 @@ contexts: - meta_scope: meta.block.js - match: \} scope: punctuation.section.block.end.js - pop: true + pop: 1 - include: ts-type-members ts-type-members: @@ -373,12 +373,12 @@ contexts: - ts-type-annotation-optional - - match: '\+|-' scope: storage.modifier.js - pop: true + pop: 1 - include: else-pop - - meta_scope: meta.brackets.js - match: \] scope: punctuation.section.brackets.end.js - pop: true + pop: 1 - match: '{{identifier_name}}' scope: variable.other.readwrite.js push: @@ -412,7 +412,7 @@ contexts: ts-type-member-name: - match: '{{identifier_name}}' scope: variable.other.readwrite.js - pop: true + pop: 1 - include: literal-string - include: literal-number @@ -432,7 +432,7 @@ contexts: ts-enum-name: - match: '{{identifier_name}}' scope: entity.name.enum.js - pop: true + pop: 1 - include: else-pop ts-enum-body: @@ -442,7 +442,7 @@ contexts: - meta_scope: meta.block.js - match: \} scope: punctuation.section.block.end.js - pop: true + pop: 1 - include: comma-separator - match: (?=['"]) push: literal-string @@ -458,7 +458,7 @@ contexts: ts-type-alias-name: - match: '{{identifier_name}}' scope: entity.name.type.js - pop: true + pop: 1 - include: else-pop ts-type-alias-body: @@ -493,7 +493,7 @@ contexts: ts-namespace-name: - match: '{{identifier_name}}' scope: entity.name.namespace.js - pop: true + pop: 1 - include: else-pop variable-binding-pattern: @@ -542,7 +542,7 @@ contexts: - meta_scope: meta.generic.js - match: \> scope: punctuation.definition.generic.end.js - pop: true + pop: 1 - match: ',' scope: punctuation.separator.comma @@ -607,7 +607,7 @@ contexts: scope: storage.modifier.js set: - match: (?={{binding_pattern_lookahead}}|\.\.\.) - pop: true + pop: 1 - match: (?=\S) fail: function-parameter-modifier @@ -660,13 +660,13 @@ contexts: scope: punctuation.definition.generic.begin.js set: - - match: (?=[\]()};,`]) - pop: true + pop: 1 - match: (?=\S) fail: ts-function-type-arguments - - meta_scope: meta.generic.js - match: \> scope: punctuation.definition.generic.end.js - pop: true + pop: 1 - match: ',' scope: punctuation.separator.comma.js push: @@ -688,7 +688,7 @@ contexts: - meta_scope: meta.assertion.js - match: \> scope: punctuation.definition.assertion.end.js - pop: true + pop: 1 ts-old-type-assertion-check: - match: (?=\() @@ -707,7 +707,7 @@ contexts: push: - match: const{{identifier_break}} scope: storage.modifier.const.js - pop: true + pop: 1 - match: (?=\S) set: - ts-type-meta @@ -728,13 +728,13 @@ contexts: ts-type-annotation-optional: - match: \? scope: storage.modifier.optional.js - pop: true + pop: 1 - include: else-pop ts-type-annotation-definite: - match: \! scope: storage.modifier.definite.js - pop: true + pop: 1 - include: else-pop ts-type-meta: @@ -793,7 +793,7 @@ contexts: ts-type-expression-end-no-line-terminator: - meta_include_prototype: false - match: '{{line_ending_ahead}}' - pop: true + pop: 1 - include: prototype - match: \[(?={{nothing}}\]) @@ -801,7 +801,7 @@ contexts: push: - match: \] scope: storage.modifier.array.js - pop: true + pop: 1 - include: else-pop - match: \[ @@ -810,7 +810,7 @@ contexts: - meta_scope: meta.brackets.js - match: \] scope: punctuation.section.brackets.end.js - pop: true + pop: 1 - match: (?=\S) push: - ts-type-expression-end @@ -828,7 +828,7 @@ contexts: - meta_scope: meta.generic.js - match: \> scope: punctuation.definition.generic.end.js - pop: true + pop: 1 - include: comma-separator - match: (?=\S) push: @@ -864,7 +864,7 @@ contexts: - meta_scope: meta.group.js - match: \) scope: punctuation.section.group.end.js - pop: true + pop: 1 - match: (?=['"]) push: literal-string - include: else-pop @@ -882,7 +882,7 @@ contexts: - ts-type-parameter-list - match: (?=\() - pop: true + pop: 1 branch_point: ts-function-type branch: - ts-type-parenthesized @@ -899,7 +899,7 @@ contexts: ts-generic-function-type-check: - match: (?=\() - pop: true + pop: 1 - match: (?=\S) pop: 2 @@ -910,7 +910,7 @@ contexts: - meta_scope: meta.sequence.js - match: \] scope: punctuation.section.sequence.end.js - pop: true + pop: 1 - include: comma-separator - match: \.\.\. scope: keyword.operator.spread.js @@ -928,53 +928,53 @@ contexts: - meta_scope: meta.mapping.js - match: \} scope: punctuation.section.mapping.end.js - pop: true + pop: 1 - include: ts-type-members ts-type-special: - match: 'any{{identifier_break}}' scope: 'support.type.any.js' - pop: true + pop: 1 - match: 'void{{identifier_break}}' scope: 'support.type.void.js' - pop: true + pop: 1 - match: 'never{{identifier_break}}' scope: 'support.type.never.js' - pop: true + pop: 1 - match: 'unknown{{identifier_break}}' scope: 'support.type.unknown.js' - pop: true + pop: 1 ts-type-primitive: - match: 'boolean{{identifier_break}}' scope: 'support.type.primitive.boolean.js' - pop: true + pop: 1 - match: 'number{{identifier_break}}' scope: 'support.type.primitive.number.js' - pop: true + pop: 1 - match: 'string{{identifier_break}}' scope: 'support.type.primitive.string.js' - pop: true + pop: 1 - match: 'null{{identifier_break}}' scope: 'support.type.primitive.null.js' - pop: true + pop: 1 - match: 'undefined{{identifier_break}}' scope: 'support.type.primitive.undefined.js' - pop: true + pop: 1 - match: 'object{{identifier_break}}' scope: 'support.type.primitive.object.js' - pop: true + pop: 1 - match: 'symbol{{identifier_break}}' scope: 'support.type.primitive.symbol.js' - pop: true + pop: 1 - match: 'bigint{{identifier_break}}' scope: 'support.type.primitive.bigint.js' - pop: true + pop: 1 ts-type-basic: - match: '{{identifier_name}}' scope: support.class.js - pop: true + pop: 1 ts-type-template-string: - match: '`' @@ -984,7 +984,7 @@ contexts: - meta_scope: meta.string.js string.quoted.other.js - match: "`" scope: punctuation.definition.string.end.js - pop: true + pop: 1 - match: '\$\{' scope: punctuation.section.interpolation.begin.js push: @@ -993,7 +993,7 @@ contexts: - meta_content_scope: source.js.embedded - match: '\}' scope: punctuation.section.interpolation.end.js - pop: true + pop: 1 - match: (?=\S) push: - ts-type-expression-end @@ -1011,7 +1011,7 @@ contexts: - - meta_scope: meta.group.js - match: \) scope: punctuation.section.group.end.js - pop: true + pop: 1 - match: (?=\S) fail: ts-function-type - ts-type-expression-end @@ -1061,6 +1061,6 @@ contexts: scope: storage.modifier.js set: - match: (?={{property_name}}) - pop: true + pop: 1 - match: (?=\S) fail: ts-object-literal-element-modifier From e5ab29824b32e85d870612f3f75a0eaa645cc93a Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sun, 19 Jun 2022 09:52:54 +0200 Subject: [PATCH 19/22] [Markdown] Add support for setext headings in list-blocks (#3399) * [Markdown] Add support for setext headings in list-blocks This commit adds `list-setext-headings-or-paragraphs` contexts which are a modified copy of `setext-headings-or-paragraphs` to support setext headings within list items. It may also be useful if markdown is to be embedded into 3rd-party syntaxes with lazy indentation handling. * [Markdown] Tweak setext heading escapes 1. `setext-heading1` is the last branch, doesn't need a failure. 2. `setext-heading2` needs to fail on setext heading level 1 only. * [Markdown] sync setext trailing whitespace patterns Both ..._escape and ..._end patterns should match the same style of trailing whitespace to avoid theoretical bugs with invisible unicode spaces. Second change causes leading whitespace at the beginning of a pragraph not to be consumed by `setext_heading_or_paragraph` pattern. This will be required for mathjax blocks. * [Markdown] Reorg paragraph-end vs. -fail Goal is same structure of both heading/paragraph sections and to make `fail` pattern available for use by other contexts. * [Markdown] Tweak setext patterns in lists This commit adds a heuristic to require at least 2 hyphens or equal signs for setext headings in list blocks in order to prevent items followed by empty items being scoped heading temporarily. The heuristic is required as we can't track indentation. --- Markdown/Markdown.sublime-syntax | 110 ++++++++++++++++++------- Markdown/tests/syntax_test_markdown.md | 54 +++++++++++- 2 files changed, 135 insertions(+), 29 deletions(-) diff --git a/Markdown/Markdown.sublime-syntax b/Markdown/Markdown.sublime-syntax index 64ee99ad7b7..bc386a0db5d 100644 --- a/Markdown/Markdown.sublime-syntax +++ b/Markdown/Markdown.sublime-syntax @@ -23,7 +23,18 @@ variables: atx_heading: (?:[ ]{,3}[#]{1,6}(?:[ \t]|$)) # between 0 and 3 spaces, followed 1 to 6 hashes, followed by at least one space or tab or by end of the line atx_heading_space: (?:(?=[ \t]+#+[ \t]*$)|[ \t]+|$) # consume spaces only if heading is not empty to ensure `atx_heading_end` can fully match closing hashes atx_heading_end: (?:[ \t]+(#+))?[ \t]*($\n?) # \n is optional so ## is matched as end punctuation in new document (at eof) - setext_escape: ^(?=[ ]{,3}(?:=+|-+)\s*$) # between 0 and 3 spaces, followed by at least one hyphon or equal sign (setext underline can be of any length) + + setext_heading_or_paragraph: ^(?:[ ]{,3}=+|(?=[ ]{,3}\S)) # between 0 and 3 spaces, followed by non-whitespace (consume equal signs as paragraphs may start with them) + setext_heading_escape: ^(?=[ ]{,3}(?:=+|-+)[ \t]*$) # between 0 and 3 spaces, followed by at least one hyphen or equal sign (setext underline can be of any length) + setext_heading1_escape: ^(?=[ ]{,3}=+[ \t]*$) # between 0 and 3 spaces, followed by at least one equal sign (setext underline can be of any length) + setext_heading1_end: ^[ ]{,3}(=+)[ \t]*$(\n?) # between 0 and 3 spaces, followed by at least one equal sign (setext underline can be of any length) + setext_heading2_end: ^[ ]{,3}(-+)[ \t]*$(\n?) # between 0 and 3 spaces, followed by at least one hyphen (setext underline can be of any length) + + list_setext_heading_or_paragraph: (?:[ \t]*=+|(?=[ \t]*\S)) # any number of spaces, followed by non-whitespace (consume equal signs as paragraphs may start with them) + list_setext_heading_escape: ^(?=[ \t]{2,}(?:==+|--+)[ \t]*$) # two or more spaces, followed by at least one hyphen or equal sign (setext underline can be of any length, but ST needs at least 2 to avoid ambiguity with empty list items) + list_setext_heading1_escape: ^(?=[ \t]{2,}==+[ \t]*$) # two or more spaces, followed by at least one equal sign (setext underline can be of any length, but ST needs at least 2 to avoid ambiguity with empty list items) + list_setext_heading1_end: ^[ \t]{2,}(==+)[ \t]*$(\n?) # two or more spaces, followed by at least one equal sign (setext underline can be of any length, but ST needs at least 2 to avoid ambiguity with empty list items) + list_setext_heading2_end: ^[ \t]{2,}(--+)[ \t]*$(\n?) # two or more spaces, followed by at least one hyphen (setext underline can be of any length, but ST needs at least 2 to avoid ambiguity with empty list items) block_quote: (?:[ ]{,3}(>)[ ]?) # between 0 and 3 spaces, followed by a greater than sign, (followed by any character or the end of the line = "only care about optional space!") indented_code_block: (?:[ ]{4}|[ ]{0,3}\t) # a visual tab of width 4 consisting of 4 spaces or 0 to 3 spaces followed by 1 tab @@ -109,7 +120,7 @@ variables: # at least 2 non-escaped pipe chars on the line (?:{{table_cell}}?\|){2} - # something other than whitespace followed by a pipe char or hyphon, + # something other than whitespace followed by a pipe char or hyphen, # followed by something other than whitespace and the end of the line | (?! \s*\-\s+ | \s+\|){{table_cell}}\|(?!\s+$) ) @@ -248,6 +259,20 @@ variables: ) ) + list_paragraph_end: |- + (?x: # pop out of this context if one of the following conditions are met: + ^(?= [ \t]* + (?: $ # the line is blank (or only contains whitespace) + | {{block_quote}} # a blockquote begins the line + | {{atx_heading}} # an ATX heading begins the line + | {{fenced_code_block_start}} # a fenced codeblock begins the line + | {{thematic_break}} # line is a thematic beak + | {{list_item}} # a list item begins the line + | {{html_block}} # a html block begins the line + ) + ) + ) + # https://spec.commonmark.org/0.30/#left-flanking-delimiter-run bold_italic_asterisk_begin: |- (?x: @@ -657,7 +682,7 @@ contexts: - include: reference-definitions - include: list-block-common - include: list-block-quotes - - include: list-paragraphs + - include: list-setext-headings-or-paragraphs list-block-common: - include: thematic-breaks @@ -715,31 +740,57 @@ contexts: - include: list-block-quote-punctuations - include: inlines - list-paragraphs: - - match: '[ \t]*(?=\S)' - push: list-paragraph-body + list-setext-headings-or-paragraphs: + # A paragraph may start with a line of equal signs which must not be matched + # as heading underline. This is achieved by consuming them here, which also + # applies `meta.paragraph` scope as expected. + # A line of dashes is already matched as thematic break and thus ignored. + - match: '{{list_setext_heading_or_paragraph}}' + branch_point: list-setext-headings-or-paragraphs + branch: + - list-paragraph + - list-setext-heading2 + - list-setext-heading1 + + list-setext-heading1: + # https://spec.commonmark.org/0.30/#setext-headings + - meta_scope: markup.heading.1.markdown + - meta_content_scope: entity.name.section.markdown + - match: '{{list_setext_heading1_end}}' + captures: + 1: punctuation.definition.heading.setext.markdown + 2: meta.whitespace.newline.markdown + pop: 1 + - include: setext-heading-content - list-paragraph-body: + list-setext-heading2: + # https://spec.commonmark.org/0.30/#setext-headings + - meta_scope: markup.heading.2.markdown + - meta_content_scope: entity.name.section.markdown + - match: '{{list_setext_heading2_end}}' + captures: + 1: punctuation.definition.heading.setext.markdown + 2: meta.whitespace.newline.markdown + pop: 1 + - match: '{{list_setext_heading1_escape}}' + fail: list-setext-headings-or-paragraphs + - include: setext-heading-content + + list-paragraph: + # https://spec.commonmark.org/0.30/#paragraphs - meta_scope: meta.paragraph.list.markdown + - include: list-paragraph-fail - include: list-paragraph-end - include: inlines list-paragraph-end: - - match: |- - (?x) - # pop out of this context if one of the following conditions are met: - ^(?= [ \t]* - (?: $ # the line is blank (or only contains whitespace) - | {{block_quote}} # a blockquote begins the line - | {{atx_heading}} # an ATX heading begins the line - | {{fenced_code_block_start}} # a fenced codeblock begins the line - | {{thematic_break}} # line is a thematic beak - | {{list_item}} # a list item begins the line - | {{html_block}} # a html block begins the line - ) - ) + - match: '{{list_paragraph_end}}' pop: 1 + list-paragraph-fail: + - match: '{{list_setext_heading_escape}}' + fail: list-setext-headings-or-paragraphs + ###[ LEAF BLOCKS: ATX HEADINGS ]############################################## atx-headings: @@ -822,7 +873,7 @@ contexts: # as heading underline. This is achieved by consuming them here, which also # applies `meta.paragraph` scope as expected. # A line of dashes is already matched as thematic break and thus ignored. - - match: ^[ ]{,3}(?:=+|(?=\S)) + - match: '{{setext_heading_or_paragraph}}' branch_point: setext-headings-or-paragraphs branch: - paragraph @@ -833,7 +884,7 @@ contexts: # https://spec.commonmark.org/0.30/#setext-headings - meta_scope: markup.heading.1.markdown - meta_content_scope: entity.name.section.markdown - - match: ^[ ]{,3}(=+)[ \t]*$(\n?) + - match: '{{setext_heading1_end}}' captures: 1: punctuation.definition.heading.setext.markdown 2: meta.whitespace.newline.markdown @@ -844,16 +895,16 @@ contexts: # https://spec.commonmark.org/0.30/#setext-headings - meta_scope: markup.heading.2.markdown - meta_content_scope: entity.name.section.markdown - - match: ^[ ]{,3}(-+)[ \t]*$(\n?) + - match: '{{setext_heading2_end}}' captures: 1: punctuation.definition.heading.setext.markdown 2: meta.whitespace.newline.markdown pop: 1 + - match: '{{setext_heading1_escape}}' + fail: setext-headings-or-paragraphs - include: setext-heading-content setext-heading-content: - - match: '{{setext_escape}}' - fail: setext-headings-or-paragraphs - include: emphasis - include: images - include: literals @@ -863,8 +914,7 @@ contexts: paragraph: # https://spec.commonmark.org/0.30/#paragraphs - meta_scope: meta.paragraph.markdown - - match: '{{setext_escape}}' - fail: setext-headings-or-paragraphs + - include: paragraph-fail - include: paragraph-end - include: inlines @@ -872,6 +922,10 @@ contexts: - match: '{{paragraph_end}}' pop: 1 + paragraph-fail: + - match: '{{setext_heading_escape}}' + fail: setext-headings-or-paragraphs + ###[ LEAF BLOCKS: INDENTED CODE BLOCKS ]###################################### indented-code-blocks: @@ -2285,7 +2339,7 @@ contexts: - include: italic emphasis-common: - - match: '{{setext_escape}}' + - match: '{{setext_heading_escape}}' pop: 1 - match: ^\s*$\n? scope: invalid.illegal.non-terminated.bold-italic.markdown diff --git a/Markdown/tests/syntax_test_markdown.md b/Markdown/tests/syntax_test_markdown.md index d7e6ec89173..e75d693e364 100644 --- a/Markdown/tests/syntax_test_markdown.md +++ b/Markdown/tests/syntax_test_markdown.md @@ -4575,7 +4575,7 @@ A list item can contain a heading: - Should be a setext heading! --- -| ^^^ markup.list.unnumbered.markdown meta.separator.thematic-break.markdown punctuation.definition.thematic-break.markdown +| ^^^ markup.list.unnumbered.markdown markup.heading.2.markdown punctuation.definition.heading.setext.markdown - Bar --- @@ -5114,6 +5114,58 @@ So is this, with a empty second item: | <- markup.list.numbered.markdown markup.heading.2.markdown punctuation.definition.heading.begin.markdown |^^^^^^^^^^^^^^^^^^^^^^ markup.list.numbered.markdown markup.heading.2.markdown +## https://custom-tests/list-blocks/items-with-setext-headings + +* list item +global heading +=== +| <- markup.list.unnumbered.markdown meta.paragraph.list.markdown +|^^^ markup.list.unnumbered.markdown meta.paragraph.list.markdown + +* list item + global heading (matched as list item heading) + === + | <- markup.list.unnumbered.markdown meta.paragraph.list.markdown + |^^^ markup.list.unnumbered.markdown meta.paragraph.list.markdown + +* list item + heading + === + | <- markup.list.unnumbered.markdown markup.heading.1.markdown punctuation.definition.heading.setext.markdown + |^^ markup.list.unnumbered.markdown markup.heading.1.markdown punctuation.definition.heading.setext.markdown + + - list item + + list item heading + --- + | <- markup.list.unnumbered.markdown markup.heading.2.markdown punctuation.definition.heading.setext.markdown + |^^ markup.list.unnumbered.markdown markup.heading.2.markdown punctuation.definition.heading.setext.markdown + + + list item + + list item heading + --- + | <- markup.list.unnumbered.markdown markup.heading.2.markdown punctuation.definition.heading.setext.markdown + |^^ markup.list.unnumbered.markdown markup.heading.2.markdown punctuation.definition.heading.setext.markdown + + - heading + --- + | <- markup.list.unnumbered.markdown markup.heading.2.markdown punctuation.definition.heading.setext.markdown + |^^ markup.list.unnumbered.markdown markup.heading.2.markdown punctuation.definition.heading.setext.markdown + + - should not be a heading, but we can't handle it yet + -- + | <- markup.list.unnumbered.markdown markup.heading.2.markdown punctuation.definition.heading.setext.markdown + |^ markup.list.unnumbered.markdown markup.heading.2.markdown punctuation.definition.heading.setext.markdown + + - list item + - + | <- markup.list.unnumbered.markdown markup.list.unnumbered.bullet.markdown punctuation.definition.list_item.markdown + + - list item + = + | <- markup.list.unnumbered.markdown meta.paragraph.list.markdown + ## https://custom-tests/list-blocks/items-with-fenced-code-blocks-indented-by-tabs * foo From e754ec43e215126911cf89c69d45080ba0cc2282 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Thu, 30 Jun 2022 17:41:23 +0200 Subject: [PATCH 20/22] [Java] Fix default method modifier (#3439) * [Java] Fix default method modifier scope Fixes #3438 This commit re-orders `declarations` and `statements` contexts to ensure to first consume `default Type method()` declarations, which is required to properly scope `default` keyword in that context. That change revealed `yield` being missing in `control_keywords` which caused it to be scoped `storage.type` in some contexts by accident. That's fixed to keep syntax tests passing. * [Java] Adjust modifier scopes This commit renames scope of `default` and `throws` keyword in context of defining method attributes to `storage.modifier`. Motivation 1. `default` is scoped `storage.modifier` in front of default method declarations and `keyword.control` in switch-case statements. A third scope for the same keyword is probably too much and may feel inconsistent. 2. `extends` or `inherits` keywords, which are used in exactly the same position (related context with regards to class/interface declarations) are scoped `storage.modifier`. 3. scope of `throws` keyword is adjusted, too, because of 2.) and to keep in consistent with scope of `default` in same position. --- Java/Java.sublime-syntax | 12 +++---- Java/tests/syntax_test_java.java | 58 +++++++++++++++++++++++++------- 2 files changed, 51 insertions(+), 19 deletions(-) diff --git a/Java/Java.sublime-syntax b/Java/Java.sublime-syntax index 85375d876f8..1bcf3b473c8 100644 --- a/Java/Java.sublime-syntax +++ b/Java/Java.sublime-syntax @@ -40,7 +40,7 @@ variables: (?x: class | enum | @?interface | record | var | void | extends | implements | import | package ) control_keywords: |- (?x: assert | break | case | catch | continue | do | else | finally | for - | if | return | switch | throw | throws | try | while ) + | if | return | switch | throw | throws | try | while | yield ) operator_keywords: |- (?x: new | instanceof ) illegal_keywords: |- @@ -131,8 +131,8 @@ contexts: - include: import - include: module - include: package - - include: statements - include: declarations + - include: statements - include: else-expressions statements: @@ -653,8 +653,8 @@ contexts: # https://docs.oracle.com/javase/specs/jls/se13/html/jls-8.html#jls-8.1.6 - meta_scope: meta.class.java meta.block.java - include: block-end - - include: member-statements - include: member-declarations + - include: member-statements - include: else-expressions ###[ ENUM DECLARATIONS ]####################################################### @@ -1135,14 +1135,14 @@ contexts: method-attributes: # https://docs.oracle.com/javase/specs/jls/se13/html/jls-8.html#jls-8.4.6 - match: throws{{break}} - scope: keyword.declaration.throws.java + scope: storage.modifier.throws.java set: - method-throws-body - maybe-illegal-array-modifiers - expect-object-type # https://docs.oracle.com/javase/specs/jls/se13/html/jls-9.html#jls-9.6.2 - match: default{{break}} - scope: keyword.declaration.default.java + scope: storage.modifier.default.java set: method-default-body - include: else-pop @@ -1764,8 +1764,8 @@ contexts: # https://docs.oracle.com/javase/specs/jls/se13/html/jls-14.html#jls-14.2 - meta_scope: meta.block.java - include: block-end - - include: statements - include: declarations + - include: statements - include: else-expressions ###[ GROUPS ]################################################################## diff --git a/Java/tests/syntax_test_java.java b/Java/tests/syntax_test_java.java index d2859e725cf..22425c427ac 100644 --- a/Java/tests/syntax_test_java.java +++ b/Java/tests/syntax_test_java.java @@ -2274,7 +2274,7 @@ interface // comment // ^^^^^^^^^^^^ entity.name.function.java // ^ punctuation.section.group.begin.java // ^ punctuation.section.group.end.java -// ^^^^^^^ keyword.declaration.default.java +// ^^^^^^^ storage.modifier.default.java // ^^ constant.numeric boolean booleanValue() default true; @@ -2288,7 +2288,7 @@ interface // comment // ^^^^^^^^^^^^ entity.name.function.java // ^ punctuation.section.group.begin.java // ^ punctuation.section.group.end.java -// ^^^^^^^ keyword.declaration.default.java +// ^^^^^^^ storage.modifier.default.java // ^^^^ constant.language char charValue() default 'S'; @@ -2302,7 +2302,7 @@ interface // comment // ^^^^^^^^^ entity.name.function.java // ^ punctuation.section.group.begin.java // ^ punctuation.section.group.end.java -// ^^^^^^^ keyword.declaration.default.java +// ^^^^^^^ storage.modifier.default.java // ^^^ string.quoted.single.java String value() default "Default value"; @@ -2316,7 +2316,7 @@ interface // comment // ^ punctuation.section.group.end.java // ^^^^^^^^^^^^^^^^^^^^^^^ meta.function.default.java // ^ - meta.function -// ^^^^^^^ keyword.declaration.default.java +// ^^^^^^^ storage.modifier.default.java // ^^^^^^^^^^^^^^^ string.quoted.double.java Class classValue() default String.class; @@ -2330,7 +2330,7 @@ interface // comment // ^^^^^^^^^^ entity.name.function.java // ^ punctuation.section.group.begin.java // ^ punctuation.section.group.end.java -// ^^^^^^^ keyword.declaration.default.java +// ^^^^^^^ storage.modifier.default.java // ^^^^^^ storage.type.class.java // ^ punctuation.accessor.dot.java // ^^^^^ variable.language.class.java - storage.type.java @@ -2348,7 +2348,7 @@ interface // comment // ^ punctuation.section.group.begin.java // ^ punctuation.section.group.end.java // ^^ storage.modifier.array.java -// ^^^^^^^ keyword.declaration.default.java +// ^^^^^^^ storage.modifier.default.java // ^ punctuation.section.braces.begin.java // ^^^^^ string.quoted.double.java // ^ punctuation.separator.comma.java @@ -3413,6 +3413,38 @@ void method() // ^^^ variable.parameter.java // ^ punctuation.terminator.java + default void method() {} +//^^^^^^^^^^^^^^^^^^^^^^^^ meta.class.java meta.block.java meta.function - meta.function meta.function +//^^^^^^^^ meta.function.modifier.java +// ^^^^^ meta.function.return-type.java +// ^^^^^^ meta.function.identifier.java +// ^^ meta.function.parameters.java meta.group.java +// ^ meta.function.java - meta.group - meta.block meta.block +// ^^ meta.function.java meta.block.java +//^^^^^^^ storage.modifier.java +// ^^^^ storage.type.void.java +// ^^^^^^ entity.name.function.java +// ^ punctuation.section.group.begin.java +// ^ punctuation.section.group.end.java +// ^ punctuation.section.block.begin.java +// ^ punctuation.section.block.end.java + + default MyType method() {} +//^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.class.java meta.block.java meta.function - meta.function meta.function +//^^^^^^^^ meta.function.modifier.java +// ^^^^^^^ meta.function.return-type.java +// ^^^^^^ meta.function.identifier.java +// ^^ meta.function.parameters.java meta.group.java +// ^ meta.function.java - meta.group - meta.block meta.block +// ^^ meta.function.java meta.block.java +//^^^^^^^ storage.modifier.java +// ^^^^^^ storage.type.class.java +// ^^^^^^ entity.name.function.java +// ^ punctuation.section.group.begin.java +// ^ punctuation.section.group.end.java +// ^ punctuation.section.block.begin.java +// ^ punctuation.section.block.end.java + static void method() //^^^^^^^^^^^^^^^^^^^^^ meta.class.java meta.block.java meta.function - meta.function meta.function //^^^^^^^ meta.function.modifier.java @@ -3627,7 +3659,7 @@ private static int methodThrows() throws MyException { // ^^^^^^^^^^^^ entity.name.function.java // ^ punctuation.section.group.begin.java // ^ punctuation.section.group.end.java -// ^^^^^^ keyword.declaration.throws.java +// ^^^^^^ storage.modifier.throws.java // ^^^^^^^^^^^ storage.type.class.java // ^ punctuation.definition.generic.begin.java // ^^^ storage.type.class.java @@ -3673,7 +3705,7 @@ private static int methodthrows() throws int {} // ^^^^^^^^^^^^ entity.name.function.java // ^ punctuation.section.group.begin.java // ^ punctuation.section.group.end.java -// ^^^^^^ keyword.declaration.throws.java +// ^^^^^^ storage.modifier.throws.java // ^^^ invalid.illegal.unexpected-keyword.java // ^ punctuation.section.block.begin.java // ^ punctuation.section.block.end.java @@ -3694,7 +3726,7 @@ private static int methodthrows() throws array[] {} // ^^^^^^^^^^^^ entity.name.function.java // ^ punctuation.section.group.begin.java // ^ punctuation.section.group.end.java -// ^^^^^^ keyword.declaration.throws.java +// ^^^^^^ storage.modifier.throws.java // ^^^^^ storage.type.class.java // ^^ invalid.illegal.unexpected-modifier.java // ^ punctuation.section.block.begin.java @@ -3717,7 +3749,7 @@ private static int methodthrows() throws myexception {} // ^^^^^^^^^^^^ entity.name.function.java // ^ punctuation.section.group.begin.java // ^ punctuation.section.group.end.java -// ^^^^^^ keyword.declaration.throws.java +// ^^^^^^ storage.modifier.throws.java // ^^^^^^^^^^^ storage.type.class.java // ^ punctuation.definition.generic.begin.java // ^^^ storage.type.class.java @@ -3746,7 +3778,7 @@ private static int methodthrows() throws java.myexception {} // ^^^^^^^^^^^^ entity.name.function.java // ^ punctuation.section.group.begin.java // ^ punctuation.section.group.end.java -// ^^^^^^ keyword.declaration.throws.java +// ^^^^^^ storage.modifier.throws.java // ^^^^ variable.namespace.java // ^ punctuation.accessor.dot.java // ^^^^^^^^^^^ storage.type.class.java @@ -4099,7 +4131,7 @@ public static T genericTypeMethod(Collection, Sink) {} //^^^^^^^^^ meta.class.java meta.block.java meta.function - meta.function meta.function //^^ meta.function.java // ^^^^^^^ meta.function.throws.java -// ^^^^^^ keyword.declaration.throws.java +// ^^^^^^ storage.modifier.throws.java Exception //^^^^^^^^^^^^^^^^ meta.function.throws.java - meta.function meta.function // ^^^^^^^^^ storage.type.class.java @@ -4145,7 +4177,7 @@ public void someReallyReallyLongMethodNameThatMakesTheBraceOverflowToTheNextLine // ^ meta.function.parameters.java variable.parameter.java // ^ punctuation.section.group.end throws Exception { -// ^ meta.function.throws.java keyword.declaration.throws.java +// ^ meta.function.throws.java storage.modifier.throws.java // ^ meta.function.throws.java storage.type.class.java return someMethod (new Function() { // ^ - meta.function-call From 0c575c36e7082ffaeb69a8c7530748351139a74b Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sun, 3 Jul 2022 19:31:53 +0200 Subject: [PATCH 21/22] [Markdown] Add support for LaTeX math blocks (#3397) Fixes #3251 --- Markdown/Markdown.sublime-syntax | 170 ++++++++++++++ Markdown/tests/syntax_test_markdown.md | 308 +++++++++++++++++++++++++ 2 files changed, 478 insertions(+) diff --git a/Markdown/Markdown.sublime-syntax b/Markdown/Markdown.sublime-syntax index bc386a0db5d..fdf7c04d912 100644 --- a/Markdown/Markdown.sublime-syntax +++ b/Markdown/Markdown.sublime-syntax @@ -292,6 +292,7 @@ variables: | \B \* {{no_space_but_punct}} ) + no_escape_behind: (?)[^\$] )*? \S\$\W ) + scope: + markup.math.inline.markdown + text.tex.latex.embedded.markdown + meta.environment.math.block.dollar.latex + punctuation.definition.math.begin.latex + embed: math-content + embed_scope: + markup.math.inline.markdown + text.tex.latex.embedded.markdown + meta.environment.math.block.dollar.latex + escape: '{{no_escape_behind}}\$' + escape_captures: + 0: markup.math.inline.markdown + text.tex.latex.embedded.markdown + meta.environment.math.block.dollar.latex + punctuation.definition.math.end.latex + + math-content: + - include: scope:text.tex.latex#macros + - include: scope:text.tex.latex#math-content + ###[ PROTOTYPES ]############################################################# else-pop: diff --git a/Markdown/tests/syntax_test_markdown.md b/Markdown/tests/syntax_test_markdown.md index e75d693e364..033aa1bac4b 100644 --- a/Markdown/tests/syntax_test_markdown.md +++ b/Markdown/tests/syntax_test_markdown.md @@ -7919,3 +7919,311 @@ This is a [[wiki link]]. | ^^^^^^^^^^^^^ meta.link.reference.wiki.description.markdown | ^^ punctuation.definition.link.begin.markdown | ^^ punctuation.definition.link.end.markdown + + +# TEST: MATHJAX BLOCKS MARKUP ################################################# + + $$ +|^^^^ meta.paragraph.markdown - markup.math + + $$ 1+1 +|^^^^^^^^ meta.paragraph.markdown - markup.math + + $$ 1+1 + $$ +| ^^ markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex punctuation.definition.math.end.latex + + $$ 1+1 $$ +|^ meta.paragraph.markdown markup.math.block.markdown - text.tex +| ^^^^^^^^^ meta.paragraph.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex +| ^ meta.paragraph.markdown markup.math.block.markdown - text.tex +| ^^ punctuation.definition.math.begin.latex +| ^^ punctuation.definition.math.end.latex + + $$ 1+1 $$ followed by text +|^ meta.paragraph.markdown - markup.math +| ^^^^^^^^^ meta.paragraph.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex +| ^^^^^^^^^^^^^^^^^^ meta.paragraph.markdown - markup.math +| ^^ punctuation.definition.math.begin.latex +| ^^ punctuation.definition.math.end.latex + + $$ 1+1 +|^ meta.paragraph.markdown - markup.math +| ^^^^^^^ meta.paragraph.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex +| ^^ punctuation.definition.math.begin.latex + $$ followed by text +| ^^ meta.paragraph.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex punctuation.definition.math.end.latex +| ^^^^^^^^^^^^^^^^^^ meta.paragraph.markdown - markup.math + + Paragraph $$ 1+1 $$ +| ^^^^^^^^^^ meta.paragraph.markdown - markup.math +| ^^^^^^^^^ meta.paragraph.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex +| ^ meta.paragraph.markdown - markup.math + + Paragraph $$ 1+1 +| ^^^^^^^^^^ meta.paragraph.markdown - markup.math +| ^^^^^^^ meta.paragraph.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex + $$ +|^^^ meta.paragraph.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex +| ^ meta.paragraph.markdown - markup.math + +$$ +1+1 +# Heading +| <- markup.heading.1.markdown punctuation.definition.heading.begin.markdown +|^^^^^^^^^ markup.heading.1.markdown + +$$ SeText heading 1 +=== +$$ +| <- meta.paragraph.markdown - markup.math + +$$ SeText heading 2 +| <- markup.heading.2.markdown entity.name.section.markdown +--- +$$ +| <- meta.paragraph.markdown - markup.math + +$$ SeText heading 2 +| <- markup.heading.2.markdown entity.name.section.markdown +--- +$$ +| <- meta.paragraph.markdown - markup.math + +Math blocks don't terminate paragraphs, but MathJax renders them as such + $$ + 1+1 + $$ +| <- meta.paragraph.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex +|^^ meta.paragraph.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex punctuation.definition.math.end.latex +| ^ meta.paragraph.markdown markup.math.block.markdown - text.tex + + $$ +| <- meta.paragraph.markdown markup.math.block.markdown - text.tex +|^^ meta.paragraph.markdown markup.math.block.markdown - text.tex +| ^^^ meta.paragraph.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex +| ^^ punctuation.definition.math.begin.latex + 1+1 + $$ +| <- meta.paragraph.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex +|^^^^ meta.paragraph.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex +| ^^ punctuation.definition.math.end.latex +| ^ meta.paragraph.markdown markup.math.block.markdown - text.tex + +$$ +| <- markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex punctuation.definition.math.begin.latex +|^^ markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex +|^ punctuation.definition.math.begin.latex +| ^ - punctuation +foo = 1 + 2 * \sqrt{a^2+b^2} +| <- markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex variable.other.math.tex +|^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex +| ^ keyword.operator.math.tex +| ^ constant.numeric.math.tex +| ^ keyword.operator.math.tex +| ^ constant.numeric.math.tex +| ^ keyword.operator.math.tex +| ^^^^^ support.function.math.tex +| ^^^^^^^^^ meta.group.brace.latex +| ^ punctuation.definition.group.brace.begin.latex +| ^ variable.other.math.tex +| ^ keyword.operator.math.tex +| ^ constant.numeric.math.tex +| ^ keyword.operator.math.tex +| ^ variable.other.math.tex +| ^ keyword.operator.math.tex +| ^ constant.numeric.math.tex +| ^ punctuation.definition.group.brace.end.latex +$$ +| <- markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex punctuation.definition.math.end.latex +|^ markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex punctuation.definition.math.end.latex +| ^ markup.math.block.markdown - text.tex + + $$ +| <- markup.raw.block.markdown +|^^^^^^ markup.raw.block.markdown + +1. Numbered List + + $$ + | <- markup.list.numbered.markdown - markup.math + |^^ markup.list.numbered.markdown - markup.math + + $$ 1+1 + | <- markup.list.numbered.markdown - markup.math + |^^^^^^ markup.list.numbered.markdown - markup.math + + $$ 1+1 $$ + | <- markup.list.numbered.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex punctuation.definition.math.begin.latex + |^^^^^^^^ markup.list.numbered.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex + |^ punctuation.definition.math.begin.latex + | ^^ punctuation.definition.math.end.latex + + $$ 1+1 $$ followed by text + | <- markup.list.numbered.markdown meta.paragraph.list.markdown - meta.math + |^^^^^^^^^ markup.list.numbered.markdown meta.paragraph.list.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex + | ^^^^^^^^^^^^^^^^^^ markup.list.numbered.markdown meta.paragraph.list.markdown - markup.math + |^^ punctuation.definition.math.begin.latex + | ^^ punctuation.definition.math.end.latex + + $$ + 1+1 + # Heading + | <- markup.heading.1.markdown punctuation.definition.heading.begin.markdown + |^^^^^^^^^ markup.heading.1.markdown + + $$ SeText heading 1 + === + $$ + | <- meta.paragraph.list.markdown - markup.math + + $$ SeText heading 2 + | <- markup.heading.2.markdown entity.name.section.markdown + --- + $$ + | <- meta.paragraph.list.markdown - markup.math + + $$ SeText heading 2 + | <- markup.heading.2.markdown entity.name.section.markdown + --- + $$ + | <- meta.paragraph.list.markdown - markup.math + + $$ 1+1 + | <- markup.list.numbered.markdown meta.paragraph.list.markdown - meta.math + |^^^^^^^ markup.list.numbered.markdown meta.paragraph.list.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex + |^^ punctuation.definition.math.begin.latex + $$ followed by text + |^^ markup.list.numbered.markdown meta.paragraph.list.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex + | ^^^^^^^^^^^^^^^^^^ markup.list.numbered.markdown meta.paragraph.list.markdown - markup.math + + Paragraph $$ 1+1 $$ + |^^^^^^^^^ markup.list.numbered.markdown meta.paragraph.list.markdown - markup.math + | ^^^^^^^^^ markup.list.numbered.markdown meta.paragraph.list.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex + | ^ markup.list.numbered.markdown meta.paragraph.list.markdown - markup.math + + Paragraph $$ 1+1 + |^^^^^^^^^ markup.list.numbered.markdown meta.paragraph.list.markdown - markup.math + | ^^^^^^^ markup.list.numbered.markdown meta.paragraph.list.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex + $$ + |^^ markup.list.numbered.markdown meta.paragraph.list.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex + | ^ markup.list.numbered.markdown meta.paragraph.list.markdown - markup.math + + Math blocks don't terminate paragraphs, but MathJax renders them as such + $$ + 1+1 + $$ + | <- markup.list.numbered.markdown meta.paragraph.list.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex punctuation.definition.math.end.latex + |^ markup.list.numbered.markdown meta.paragraph.list.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex punctuation.definition.math.end.latex + | ^ markup.list.numbered.markdown meta.paragraph.list.markdown - text.tex + + $$ + | <- markup.list.numbered.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex punctuation.definition.math.begin.latex + |^ markup.list.numbered.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex punctuation.definition.math.begin.latex + foo = 1 + 2 + | <- markup.list.numbered.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex variable.other.math.tex + $$ + | <- markup.list.numbered.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex punctuation.definition.math.end.latex + |^ markup.list.numbered.markdown markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex punctuation.definition.math.end.latex + +# TEST: MATHJAX INLINE MARKUP ################################################# + +# Math $1+1$ atx heading +| <- markup.heading.1.markdown punctuation.definition.heading.begin.markdown +|^^^^^^^^^^^^^^^^^^^^^^^^ markup.heading.1.markdown +| ^^^^^ markup.math.inline.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex + +Math $1+1$ setext heading +| <- markup.heading.1.markdown +|^^^^^^^^^^^^^^^^^^^^^^^^^ markup.heading.1.markdown +| ^^^^^ markup.math.inline.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex +=== +| <- markup.heading.1.markdown punctuation.definition.heading.setext.markdown + +Math $1+1$ setext heading +| <- markup.heading.2.markdown +|^^^^^^^^^^^^^^^^^^^^^^^^^ markup.heading.2.markdown +| ^^^^^ markup.math.inline.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex +--- +| <- markup.heading.2.markdown punctuation.definition.heading.setext.markdown + +This is math $1+1$ expression, but $ 1+1 $ ,$ 1+1$, $1+1 $ and 1+1$ or $1+1 are not. +| ^^^^^ meta.paragraph.markdown markup.math.inline.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex +| ^ punctuation.definition.math.begin.latex +| ^ constant.numeric.math.tex +| ^ keyword.operator.math.tex +| ^ constant.numeric.math.tex +| ^ punctuation.definition.math.end.latex +| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.paragraph.markdown - markup.math + +Math with -$1$() $2$-$3$a or $4$_ +| ^^^ meta.paragraph.markdown markup.math.inline.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex +| ^^^ meta.paragraph.markdown - markup.math +| ^^^ meta.paragraph.markdown markup.math.inline.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex +| ^^^^^^^^^^^^^^ meta.paragraph.markdown - markup.math + +Use `\$` to display a dollar sign: $\sqrt{\$4}$ +| ^^^^ meta.paragraph.markdown markup.raw.inline.markdown +| ^^^^^^^^^^^^ meta.paragraph.markdown markup.math.inline.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex +| ^ punctuation.definition.math.begin.latex +| ^^^^^ support.function.math.tex +| ^ punctuation.definition.group +| ^^ constant.character.escape +| ^ constant.numeric +| ^ punctuation.definition +| ^ punctuation.definition.math.end.latex + +No math $1+1$ or $1+1$ +|^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.paragraph.markdown - markup.math + +No math $
1+1$ or $1+1
$ +|^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.paragraph.markdown - markup.math + +Math $aa$ $a $1+1$ or $1+1$ + |^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.list.numbered.markdown meta.paragraph.list.markdown - markup.math + + No math $
1+1$ or $1+1
$ + |^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.list.numbered.markdown meta.paragraph.list.markdown - markup.math + + Math $aa$ $a Date: Sun, 3 Jul 2022 19:38:01 +0200 Subject: [PATCH 22/22] [CSS] Unbind css.liquid extension (#3440) Proper syntax highlighting of CSS files with liquid interpolation is provided by https://github.com/SublimeText/Liquid Using default CSS syntax for such files may cause highlighting issues as soon as Liquid style interpolation is used. Example: ``` a { font-{{family}}: "{{font}}"; } ``` --- CSS/CSS.sublime-syntax | 1 - 1 file changed, 1 deletion(-) diff --git a/CSS/CSS.sublime-syntax b/CSS/CSS.sublime-syntax index 82e4f6b90b5..5e3d8582f1d 100644 --- a/CSS/CSS.sublime-syntax +++ b/CSS/CSS.sublime-syntax @@ -8,7 +8,6 @@ version: 2 file_extensions: - css - - css.liquid ###############################################################################