From 85065ad109a05c06a9105981cba7e0392c0fe544 Mon Sep 17 00:00:00 2001 From: eugenesvk Date: Mon, 31 Jul 2023 20:11:17 +0700 Subject: [PATCH] move macros to separate groups for easier override --- RustEnhanced.sublime-syntax | 76 ++++++++++++++++++++----------------- 1 file changed, 42 insertions(+), 34 deletions(-) diff --git a/RustEnhanced.sublime-syntax b/RustEnhanced.sublime-syntax index 5d83a8b..5bc3002 100644 --- a/RustEnhanced.sublime-syntax +++ b/RustEnhanced.sublime-syntax @@ -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 @@ -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: