Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 37 additions & 1 deletion NgxHTML.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ contexts:
ng-expressions:
# https://angular.dev/guide/templates/expression-syntax
- include: ng-arrays
- include: ng-arrow-functions
- include: ng-groups
- include: ng-objects
- include: ng-function-calls
Expand Down Expand Up @@ -458,6 +459,39 @@ contexts:
pop: 1
- include: ng-expressions

###[ ANGULAR ARROW FUNCTIONS ]#################################################

ng-arrow-functions:
# single param without parens: x =>
- match: '{{ident_name}}(?=\s*=>)'
scope: variable.parameter.ngx
# grouped params: (x) => or (x, y) =>
- match: \(
scope: punctuation.section.group.begin.ngx
branch_point: ng-arrow-params
branch:
- ng-arrow-params-body
- ng-group-body

ng-arrow-params-body:
- meta_scope: meta.group.ngx
- match: \)
scope: punctuation.section.group.end.ngx
set: ng-after-arrow-params
- match: ','
scope: punctuation.separator.parameters.ngx
- match: '{{ident_name}}'
scope: variable.parameter.ngx
- match: (?=\S)
fail: ng-arrow-params

ng-after-arrow-params:
- match: '=>'
scope: keyword.declaration.function.arrow.ngx
pop: 1
- match: (?=\S)
fail: ng-arrow-params

###[ ANGULAR OBJECTS ]#########################################################

ng-objects:
Expand Down Expand Up @@ -561,6 +595,8 @@ contexts:
scope: punctuation.separator.sequence.ngx
- match: ';'
scope: punctuation.terminator.expression.ngx
- match: '=>'
Comment thread
princemaple marked this conversation as resolved.
scope: keyword.declaration.function.arrow.ngx
- match: (?:\*\*|&&|\|\||\?\?|[-+*/%])=
scope: keyword.operator.assignment.augmented.ngx
- match: '[!=]==?|[<>]=?'
Expand All @@ -578,7 +614,7 @@ contexts:
push: ng-ternary-expression
- match: in{{ident_break}}
scope: keyword.operator.comparison.ngx
- match: (?:typeof|void){{ident_break}}
- match: (?:typeof|void|instanceof){{ident_break}}
scope: keyword.operator.type.ngx

ng-ternary-expression:
Expand Down
27 changes: 27 additions & 0 deletions tests/syntax_test_scopes.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -823,6 +823,33 @@
<!-- ^^^^ keyword.operator.type.ngx -->
<!-- ^^ meta.number.integer.decimal.ngx constant.numeric.value.ngx -->

{{ obj instanceof SomeClass }}
<!-- ^^^ variable.other.readwrite.ngx -->
<!-- ^^^^^^^^^^ keyword.operator.type.ngx -->
<!-- ^^^^^^^^^ variable.other.readwrite.ngx -->

<!-- arrow functions -->
{{ (x) => x * 2 }}
<!-- ^ punctuation.section.group.begin.ngx -->
<!-- ^ variable.parameter.ngx -->
<!-- ^ punctuation.section.group.end.ngx -->
<!-- ^^ keyword.declaration.function.arrow.ngx -->
<!-- ^ variable.other.readwrite.ngx -->
<!-- ^ keyword.operator.arithmetic.ngx -->

{{ items.filter(item => item.active) }}
<!-- ^^^^^ variable.other.object.ngx -->
<!-- ^ punctuation.accessor.ngx -->
<!-- ^^^^^^ variable.function.method.ngx -->
<!-- ^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.ngx -->
<!-- ^ punctuation.section.arguments.begin.ngx -->
<!-- ^^^^ variable.parameter.ngx -->
<!-- ^^ keyword.declaration.function.arrow.ngx -->
<!-- ^^^^ variable.other.object.ngx -->
<!-- ^ punctuation.accessor.ngx -->
<!-- ^^^^^^ variable.other.member.ngx -->
<!-- ^ punctuation.section.arguments.end.ngx -->

<!-- property subscription -->
{{ person['name'][0] = "Mirabel" }}
<!--^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.embedded.expression.ngx.html -->
Expand Down
Loading