Skip to content
Open
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
76 changes: 42 additions & 34 deletions RustEnhanced.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -146,40 +146,7 @@ contexts:
- include: strings
- include: chars

# macros which take format specs as the only parameter
- match: '\b((?:format(?:_args)?|e?print(?:ln)?|panic|unreachable|unimplemented)!)\s*(\()'
captures:
1: support.macro.rust
2: meta.group.rust punctuation.section.group.begin.rust
push:
- meta_content_scope: meta.group.rust
- include: comments
- include: format-string
- include: format-raw-string
- match: '(?=\S)'
set: group-tail

# macros which take format specs as the second parameter
- match: '\b((?:write(?:ln)?|(?:debug_)?assert)!)\s*(\()'
captures:
1: support.macro.rust
2: meta.group.rust punctuation.section.group.begin.rust
push:
- meta_scope: meta.group.rust
- include: comments
- match: ','
set:
- meta_content_scope: meta.group.rust
- include: format-string
- include: format-raw-string
- match: '(?=\S)'
set: group-tail
- include: group-tail

# macros which take format specs as the third parameter
# - match: '\b((?:assert_eq|assert_ne|debug_assert_eq|debug_assert_ne)!)\s*(\()'
# is more performant as the below
# - match: '\b((?:debug_)?assert_(?:eq|ne)!)\s*(\()'
- include: macros

- match: '\b{{identifier}}!(?=\s*(\(|\{|\[))'
scope: support.macro.rust
Expand Down Expand Up @@ -1232,6 +1199,47 @@ contexts:
- include: char
- include: byte

macros:
- include: macros-fmt-only
- include: macros-fmt-second

macros-fmt-only:
# macros which take format specs as the only parameter
- match: '\b((?:format(?:_args)?|e?print(?:ln)?|panic|unreachable|unimplemented)!)\s*(\()'
captures:
1: support.macro.rust
2: meta.group.rust punctuation.section.group.begin.rust
push:
- meta_content_scope: meta.group.rust
- include: comments
- include: format-string
- include: format-raw-string
- match: '(?=\S)'
set: group-tail

macros-fmt-second:
# macros which take format specs as the second parameter
- match: '\b((?:write(?:ln)?|(?:debug_)?assert)!)\s*(\()'
captures:
1: support.macro.rust
2: meta.group.rust punctuation.section.group.begin.rust
push:
- meta_scope: meta.group.rust
- include: comments
- match: ','
set:
- meta_content_scope: meta.group.rust
- include: format-string
- include: format-raw-string
- match: '(?=\S)'
set: group-tail
- include: group-tail

# macros which take format specs as the third parameter
# - match: '\b((?:assert_eq|assert_ne|debug_assert_eq|debug_assert_ne)!)\s*(\()'
# is more performant as the below
# - match: '\b((?:debug_)?assert_(?:eq|ne)!)\s*(\()'

byte:
- match: "(b)(')"
captures:
Expand Down