From 68cb0a9b3fb7e632640b5337d3dd39d304ea727c Mon Sep 17 00:00:00 2001 From: daladim Date: Thu, 23 Oct 2025 16:35:49 +0200 Subject: [PATCH] Added the "negation" semantic token --- .../crates/ide/src/syntax_highlighting/highlight.rs | 2 +- .../rust-analyzer/crates/ide/src/syntax_highlighting/tags.rs | 5 ++++- .../crates/rust-analyzer/src/lsp/semantic_tokens.rs | 1 + .../rust-analyzer/crates/rust-analyzer/src/lsp/to_proto.rs | 1 + 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/highlight.rs b/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/highlight.rs index d73575fb9549..829d1279a839 100644 --- a/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/highlight.rs +++ b/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/highlight.rs @@ -137,7 +137,7 @@ fn punctuation( } (T![!], MACRO_RULES) => HlPunct::MacroBang.into(), (T![!], NEVER_TYPE) => HlTag::BuiltinType.into(), - (T![!], PREFIX_EXPR) => HlOperator::Logical.into(), + (T![!], PREFIX_EXPR) => HlOperator::Negation.into(), (T![*], PTR_TYPE) => HlTag::Keyword.into(), (T![*], PREFIX_EXPR) => { let h = HlTag::Operator(HlOperator::Other).into(); diff --git a/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/tags.rs b/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/tags.rs index 4b8762640c74..456a61298741 100644 --- a/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/tags.rs +++ b/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/tags.rs @@ -124,8 +124,10 @@ pub enum HlOperator { Bitwise, /// +, -, *, /, +=, -=, *=, /= Arithmetic, - /// &&, ||, ! + /// &&, || Logical, + /// ! + Negation, /// >, <, ==, >=, <=, != Comparison, /// Other operators @@ -194,6 +196,7 @@ impl HlTag { HlOperator::Arithmetic => "arithmetic", HlOperator::Logical => "logical", HlOperator::Comparison => "comparison", + HlOperator::Negation => "negation", HlOperator::Other => "operator", }, HlTag::StringLiteral => "string_literal", diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/lsp/semantic_tokens.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/lsp/semantic_tokens.rs index 3c21e1992525..828118a0866d 100644 --- a/src/tools/rust-analyzer/crates/rust-analyzer/src/lsp/semantic_tokens.rs +++ b/src/tools/rust-analyzer/crates/rust-analyzer/src/lsp/semantic_tokens.rs @@ -91,6 +91,7 @@ define_semantic_token_types![ (LIFETIME, "lifetime"), (LOGICAL, "logical") => OPERATOR, (MACRO_BANG, "macroBang") => MACRO, + (NEGATION, "negation") => OPERATOR, (PARENTHESIS, "parenthesis"), (PROC_MACRO, "procMacro") => MACRO, (PUNCTUATION, "punctuation"), diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/lsp/to_proto.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/lsp/to_proto.rs index cd384ca713ec..2d2dacbe2e15 100644 --- a/src/tools/rust-analyzer/crates/rust-analyzer/src/lsp/to_proto.rs +++ b/src/tools/rust-analyzer/crates/rust-analyzer/src/lsp/to_proto.rs @@ -840,6 +840,7 @@ fn semantic_token_type_and_modifiers( HlOperator::Bitwise => types::BITWISE, HlOperator::Arithmetic => types::ARITHMETIC, HlOperator::Logical => types::LOGICAL, + HlOperator::Negation => types::NEGATION, HlOperator::Comparison => types::COMPARISON, HlOperator::Other => types::OPERATOR, },