From 61e575547c2f5e7cfd7b370590eabf3427bbfa2c Mon Sep 17 00:00:00 2001
From: ozacod <47009516+ozacod@users.noreply.github.com>
Date: Tue, 10 Feb 2026 14:44:23 +0300
Subject: [PATCH] languages: Change syntax highlighting for C/C++ preprocessor
directives (#48109)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This changes the highlight capture for preprocessor directives from
`@keyword.directive` to `@preproc` in both C and C++.
PR #44043 changed C from `@keyword` to `@keyword.directive` for
consistency with C++, but `@keyword.directive` is still semantically
wrong. Preprocessor directives are not language keywords — they are
instructions to a separate preprocessing phase that runs before
compilation.
Using `@preproc` reflects this distinction and allows themes to style
them independently from actual language keywords like `const`,
`struct`,`if`, etc. This is consistent with how editors like CLion
handle preprocessor directives.
Before:
After:
Release Notes:
- C/C++: Syntax highlighting for preprocessor directives can now be
tweaked with @preproc capture group.
Co-authored-by: ozacod
---
crates/languages/src/c/highlights.scm | 2 +-
crates/languages/src/cpp/highlights.scm | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/crates/languages/src/c/highlights.scm b/crates/languages/src/c/highlights.scm
index 0ba43f2f7c6422271d476ba415bea5a42beb9c41..e426bd4f9048a96c09aef297f95c420c9ec21458 100644
--- a/crates/languages/src/c/highlights.scm
+++ b/crates/languages/src/c/highlights.scm
@@ -38,7 +38,7 @@
"#ifndef"
"#include"
(preproc_directive)
-] @keyword.directive
+] @preproc
[
"="
diff --git a/crates/languages/src/cpp/highlights.scm b/crates/languages/src/cpp/highlights.scm
index 234605409c16a97fa07f126cb79dbd3a1043202d..dbb79e69b04e351ca231b45b21507e305b2cabf5 100644
--- a/crates/languages/src/cpp/highlights.scm
+++ b/crates/languages/src/cpp/highlights.scm
@@ -186,7 +186,7 @@ type: (primitive_type) @type.builtin
"#ifndef"
"#include"
(preproc_directive)
-] @keyword.directive
+] @preproc
(comment) @comment