Skip to content

Commit

Permalink
move macros to separate groups for easier override
Browse files Browse the repository at this point in the history
  • Loading branch information
eugenesvk committed Sep 14, 2023
1 parent 2ef194a commit 85065ad
Showing 1 changed file with 42 additions and 34 deletions.
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

0 comments on commit 85065ad

Please sign in to comment.