Files
oak-gpui/crates/languages/src/rust/highlights.scm
T
Marshall Bowers 2dc4f156b3 Revert "Capture shorthand_field_initializer and modules in Rust highlights (#35842)" (#36880)
This PR reverts https://github.com/zed-industries/zed/pull/35842, as it
broke the syntax highlighting for `crate`:

### Before Revert

<img width="367" height="70" alt="Screenshot 2025-08-25 at 11 29 50 AM"
src="https://github.com/user-attachments/assets/ce9b8b59-4e89-43ed-84c7-95c0156b9168"
/>

### After Revert

<img width="353" height="69" alt="Screenshot 2025-08-25 at 11 32 17 AM"
src="https://github.com/user-attachments/assets/b6df5a21-64db-4abf-aa76-f085236da0c4"
/>

This reverts commit 896a35f7be.

Release Notes:

- Reverted https://github.com/zed-industries/zed/pull/35842.
2025-08-25 15:51:31 +00:00

207 lines
3.2 KiB
Scheme

(identifier) @variable
(metavariable) @variable
(type_identifier) @type
(fragment_specifier) @type
(primitive_type) @type.builtin
(self) @variable.special
(field_identifier) @property
(trait_item name: (type_identifier) @type.interface)
(impl_item trait: (type_identifier) @type.interface)
(abstract_type trait: (type_identifier) @type.interface)
(dynamic_type trait: (type_identifier) @type.interface)
(trait_bounds (type_identifier) @type.interface)
(call_expression
function: [
(identifier) @function
(scoped_identifier
name: (identifier) @function)
(field_expression
field: (field_identifier) @function.method)
])
(generic_function
function: [
(identifier) @function
(scoped_identifier
name: (identifier) @function)
(field_expression
field: (field_identifier) @function.method)
])
(function_item name: (identifier) @function.definition)
(function_signature_item name: (identifier) @function.definition)
(macro_invocation
macro: [
(identifier) @function.special
(scoped_identifier
name: (identifier) @function.special)
])
(macro_definition
name: (identifier) @function.special.definition)
; Identifier conventions
; Assume uppercase names are types/enum-constructors
((identifier) @type
(#match? @type "^[A-Z]"))
; Assume all-caps names are constants
((identifier) @constant
(#match? @constant "^_*[A-Z][A-Z\\d_]*$"))
[
"("
")"
"{"
"}"
"["
"]"
] @punctuation.bracket
(_
.
"<" @punctuation.bracket
">" @punctuation.bracket)
[
"."
";"
","
"::"
] @punctuation.delimiter
[
"#"
] @punctuation.special
[
"as"
"async"
"await"
"break"
"const"
"continue"
"default"
"dyn"
"else"
"enum"
"extern"
"fn"
"for"
"if"
"impl"
"in"
"let"
"loop"
"macro_rules!"
"match"
"mod"
"move"
"pub"
"raw"
"ref"
"return"
"static"
"struct"
"trait"
"type"
"union"
"unsafe"
"use"
"where"
"while"
"yield"
(crate)
(mutable_specifier)
(super)
] @keyword
[
(string_literal)
(raw_string_literal)
(char_literal)
] @string
(escape_sequence) @string.escape
[
(integer_literal)
(float_literal)
] @number
(boolean_literal) @boolean
[
(line_comment)
(block_comment)
] @comment
[
(line_comment (doc_comment))
(block_comment (doc_comment))
] @comment.doc
[
"!="
"%"
"%="
"&"
"&="
"&&"
"*"
"*="
"+"
"+="
"-"
"-="
"->"
".."
"..="
"..."
"/="
":"
"<<"
"<<="
"<"
"<="
"="
"=="
"=>"
">"
">="
">>"
">>="
"@"
"^"
"^="
"|"
"|="
"||"
"?"
] @operator
; Avoid highlighting these as operators when used in doc comments.
(unary_expression "!" @operator)
operator: "/" @operator
(lifetime) @lifetime
(parameter (identifier) @variable.parameter)
(attribute_item (attribute [
(identifier) @attribute
(scoped_identifier name: (identifier) @attribute)
]))
(inner_attribute_item (attribute [
(identifier) @attribute
(scoped_identifier name: (identifier) @attribute)
]))
; Match nested snake case identifiers in attribute items.
(token_tree (identifier) @attribute (#match? @attribute "^[a-z\\d_]*$"))
; Override the attribute match for paths in scoped type/enum identifiers.
(token_tree (identifier) @variable "::" (identifier) @type (#match? @type "^[A-Z]"))