Files
oak-gpui/crates/languages/src/c/highlights.scm
T
chbkandMarshall Bowers 144d8a1db6 Improve C and C++ syntax highlighting (#25325)
Release Notes:

  - Improved C and C++ syntax highlighting.

| Zed 0.174.6 | With this PR |
| --- | --- |
|
![Image](https://github.com/user-attachments/assets/fa5bf2e0-c682-4e6a-ab64-bb873579d47c)
|
![Image](https://github.com/user-attachments/assets/dc980de9-cd6a-4b0b-8ddc-ac705f687910)
|

- `NULL`, `nullptr`: `constant` -> `constant.builtin`

```cpp
#include <stdbool.h>
int a[] = {true, false};
const int * IDENTIFIER = nullptr;
```

---------

Co-authored-by: Marshall Bowers <git@maxdeviant.com>
2025-02-21 12:01:39 -05:00

132 lines
1.4 KiB
Scheme

[
"break"
"case"
"const"
"continue"
"default"
"do"
"else"
"enum"
"extern"
"for"
"goto"
"if"
"inline"
"return"
"sizeof"
"static"
"struct"
"switch"
"typedef"
"union"
"volatile"
"while"
] @keyword
[
"#define"
"#elif"
"#else"
"#endif"
"#if"
"#ifdef"
"#ifndef"
"#include"
(preproc_directive)
] @keyword
[
"="
"+="
"-="
"*="
"/="
"%="
"&="
"|="
"^="
"<<="
">>="
"++"
"--"
"+"
"-"
"*"
"/"
"%"
"~"
"&"
"|"
"^"
"<<"
">>"
"!"
"&&"
"||"
"=="
"!="
"<"
">"
"<="
">="
"->"
"?"
":"
] @operator
[
"."
";"
","
] @punctuation.delimiter
[
"{"
"}"
"("
")"
"["
"]"
] @punctuation.bracket
[
(string_literal)
(system_lib_string)
(char_literal)
] @string
(comment) @comment
(number_literal) @number
[
(true)
(false)
] @boolean
(null) @constant.builtin
(identifier) @variable
((identifier) @constant
(#match? @constant "^_*[A-Z][A-Z\\d_]*$"))
(call_expression
function: (identifier) @function)
(call_expression
function: (field_expression
field: (field_identifier) @function))
(function_declarator
declarator: (identifier) @function)
(preproc_function_def
name: (identifier) @function.special)
(field_identifier) @property
(statement_identifier) @label
[
(type_identifier)
(primitive_type)
(sized_type_specifier)
] @type