From 7983c71752e2443266ecc65581f3a980696cc294 Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Tue, 14 Jun 2022 10:35:36 -0700 Subject: [PATCH] Introduce storage_class highlight scope (#2731) --- book/src/themes.md | 1 + runtime/queries/c/highlights.scm | 4 ++-- runtime/queries/rust/highlights.scm | 18 ++++++++++++------ 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/book/src/themes.md b/book/src/themes.md index 7562b2056bef..4c0eda228bdc 100644 --- a/book/src/themes.md +++ b/book/src/themes.md @@ -151,6 +151,7 @@ We use a similar set of scopes as - `operator` - `or`, `in` - `directive` - Preprocessor directives (`#if` in C) - `function` - `fn`, `func` + - `storage` - Keywords that affect the storage of a variable, function or data structure `static`, `mut`, `const`, `ref` - `operator` - `||`, `+=`, `>` diff --git a/runtime/queries/c/highlights.scm b/runtime/queries/c/highlights.scm index 918f3f66bc08..1263cff62289 100644 --- a/runtime/queries/c/highlights.scm +++ b/runtime/queries/c/highlights.scm @@ -1,8 +1,9 @@ +(storage_class_specifier) @keyword.storage + "goto" @keyword "register" @keyword "break" @keyword "case" @keyword -"const" @keyword "continue" @keyword "default" @keyword "do" @keyword @@ -14,7 +15,6 @@ "inline" @keyword "return" @keyword "sizeof" @keyword -"static" @keyword "struct" @keyword "switch" @keyword "typedef" @keyword diff --git a/runtime/queries/rust/highlights.scm b/runtime/queries/rust/highlights.scm index 26496c66bd1f..99cb83813d1a 100644 --- a/runtime/queries/rust/highlights.scm +++ b/runtime/queries/rust/highlights.scm @@ -156,16 +156,22 @@ "macro_rules!" "let" - "ref" - "move" - "dyn" - "static" - "const" "async" ] @keyword -(mutable_specifier) @keyword.mut +(mutable_specifier) @keyword.storage.modifier.mut + +(reference_type "&" @keyword.storage.modifier.ref) +(self_parameter "&" @keyword.storage.modifier.ref) + +[ + "static" + "const" + "ref" + "move" + "dyn" +] @keyword.storage.modifier ; TODO: variable.mut to highlight mutable identifiers via locals.scm