From 8f5513a1f2ec6ee5b378c2e32e53fc3c2a8f1e13 Mon Sep 17 00:00:00 2001 From: Jaehwang Jung Date: Sat, 16 Mar 2024 14:39:24 +0900 Subject: [PATCH] feat(rust,lalrpop): `@attribute` for lifetimes `@keyword` is only for language-defined keywords. --- CONTRIBUTING.md | 2 +- queries/lalrpop/highlights.scm | 9 ++++++++- queries/rust/highlights.scm | 12 ++++++++---- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b024961a9..8e3081e82 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -140,7 +140,7 @@ As languages differ quite a lot, here is a set of captures available to you when @type.builtin ; built-in types @type.definition ; identifiers in type definitions (e.g. `typedef ` in C) -@attribute ; attribute annotations (e.g. Python decorators) +@attribute ; attribute annotations (e.g. Python decorators, Rust lifetimes) @attribute.builtin ; builtin annotations (e.g. `@property` in Python) @property ; the key in key/value pairs ``` diff --git a/queries/lalrpop/highlights.scm b/queries/lalrpop/highlights.scm index a3cf8d897..951192ea8 100644 --- a/queries/lalrpop/highlights.scm +++ b/queries/lalrpop/highlights.scm @@ -72,7 +72,14 @@ ] @punctuation.delimiter (lifetime - (identifier) @keyword.modifier) + "'" @keyword.modifier) + +(lifetime + (identifier) @attribute) + +(lifetime + (identifier) @attribute.builtin + (#any-of? @attribute.builtin "static" "_")) (string_literal) @string diff --git a/queries/rust/highlights.scm b/queries/rust/highlights.scm index 7b229984f..64976b663 100644 --- a/queries/rust/highlights.scm +++ b/queries/rust/highlights.scm @@ -285,10 +285,14 @@ ] @keyword.modifier (lifetime - [ - "'" - (identifier) - ] @keyword.modifier) + "'" @keyword.modifier) + +(lifetime + (identifier) @attribute) + +(lifetime + (identifier) @attribute.builtin + (#any-of? @attribute.builtin "static" "_")) "fn" @keyword.function