Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Special highlighting for variable props #1315

Merged
merged 2 commits into from
Jan 6, 2022
Merged
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
30 changes: 21 additions & 9 deletions packages/svelte-vscode/syntaxes/svelte.tmLanguage.src.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -339,17 +339,26 @@ repository:
# Matches attribute keyvalues. (and boolean attributes as well)
# e.g. `class="my-class"`
attributes-keyvalue:
begin: ([_$[:alpha:]][_\-$[:alnum:]]*)
beginCaptures: { 1: { name: entity.other.attribute-name.svelte } }
begin: ((?:--)?[_$[:alpha:]][_\-$[:alnum:]]*)
beginCaptures:
0:
patterns:
# Matches if the key is a `--css-variable` attribute.
- match: --.*
name: support.type.property-name.svelte
# Matches everything else.
- match: .*
name: entity.other.attribute-name.svelte
end: (?=\s*+[^=\s])
name: 'meta.attribute.$1.svelte'
patterns: [ include: '#attributes-value' ]
patterns:
- begin: '='
beginCaptures: { 0: { name: punctuation.separator.key-value.svelte } }
end: (?<=[^\s=])(?!\s*=)|(?=/?>)
patterns: [include: '#attributes-value']

# The value part of attribute keyvalues. e.g. `="my-class"` in `class="my-class"`
# The value part of attribute keyvalues. e.g. `"my-class"` in `class="my-class"`
attributes-value:
begin: '='
dummdidumm marked this conversation as resolved.
Show resolved Hide resolved
beginCaptures: { 0: { name: punctuation.separator.key-value.svelte } }
end: (?<=[^\s=])(?!\s*=)|(?=/?>)
patterns:
# No quotes - just an interpolation expression.
- include: '#interpolation'
Expand All @@ -365,7 +374,7 @@ repository:
- begin: (['"])
end: \1
beginCaptures: { 0: { name: punctuation.definition.string.begin.svelte } }
endCaptures: { 0: { name: punctuation.definition.string.end.svelte } }
endCaptures: { 0: { name: punctuation.definition.string.end.svelte } }
name: string.quoted.svelte
patterns: [ include: '#interpolation' ]

Expand Down Expand Up @@ -419,7 +428,10 @@ repository:
end: (?=\s*+[^=\s])
name: meta.directive.$1.svelte
patterns:
- include: '#attributes-value'
- begin: '='
beginCaptures: { 0: { name: punctuation.separator.key-value.svelte } }
end: (?<=[^\s=])(?!\s*=)|(?=/?>)
patterns: [include: '#attributes-value']

# ------
# TAGS
Expand Down