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
41 changes: 22 additions & 19 deletions Rust/Rust.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ contexts:
shebang:
- meta_include_prototype: false
# allow extending syntaxes like Markdown to ignore indentation restrictions
- match: \s*(\#!)
- match: \s*(\#!)(?!\[)
captures:
1: punctuation.definition.comment.rust
set: shebang-body
Expand Down Expand Up @@ -362,31 +362,38 @@ contexts:
- match: '{{identifier}}'
scope: meta.path.rust variable.annotation.rust
- match: '\('
scope: meta.annotation.parameters.rust meta.group.rust punctuation.section.group.begin.rust
scope: punctuation.section.group.begin.rust
push:
- meta_content_scope: meta.annotation.parameters.rust meta.group.rust
- meta_scope: meta.annotation.parameters.rust meta.group.rust
- match: \)
scope: meta.annotation.parameters.rust meta.group.rust punctuation.section.group.end.rust
scope: punctuation.section.group.end.rust
pop: true
- include: attribute-call
- match: '='
scope: keyword.operator.assignment.rust
set:
- meta_content_scope: meta.annotation.rust
- include: strings
- include: chars
- include: bytes
- include: numbers
- include: comments
- match: '\]'
scope: meta.annotation.rust punctuation.section.group.end.rust
pop: true
set: attribute-contents
- match: '\]'
scope: punctuation.section.group.end.rust
pop: true
- include: comments

attribute-contents:
- meta_content_scope: meta.annotation.rust
- include: strings
- include: chars
- include: bytes
- include: numbers
- include: comments
- include: macro-identifiers
- match: \(
scope: meta.function-call.rust meta.group.rust punctuation.section.group.begin.rust
push: attribute-call
- match: '\]'
scope: meta.annotation.rust punctuation.section.group.end.rust
pop: true

attribute-call:
- meta_content_scope: meta.function-call.rust meta.group.rust
- match: \)
scope: meta.function-call.rust meta.group.rust punctuation.section.group.end.rust
pop: true
Expand All @@ -406,11 +413,7 @@ contexts:
scope: punctuation.separator.rust
- match: '='
scope: keyword.operator.assignment.rust
- include: strings
- include: chars
- include: bytes
- include: numbers
- include: comments
- include: attribute-contents
- include: lifetime
- include: keywords
- include: symbols
Expand Down
15 changes: 15 additions & 0 deletions Rust/tests/syntax_test_attributes.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
// SYNTAX TEST "Packages/Rust/Rust.sublime-syntax"

#![doc = include_str!("docs/intro.md")]
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.annotation
//^ punctuation.section.group.begin
// ^^^ variable.annotation
// ^ keyword.operator.assignment
// ^^^^^^^^^^^^ support.macro
// ^^^^^^^^^^^^^^^^^ meta.function-call meta.group
// ^ punctuation.section.group.begin
// ^^^^^^^^^^^^^^^ string.quoted.double
// ^ punctuation.definition.string.begin
// ^ punctuation.definition.string.end
// ^ punctuation.section.group.end
// ^ punctuation.section.group.end - meta.function-call
// ^ - meta.annotation

#![warn(unused)]
// <- meta.annotation punctuation.definition.annotation
//^^^^^^^^^^^^^^ meta.annotation
Expand Down