Skip to content

move macros to separate groups for easier override #515

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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