From e033829ef27a704e6704d51f4915b48767545c63 Mon Sep 17 00:00:00 2001 From: Vinh Tran Date: Thu, 20 Nov 2025 21:52:15 +0700 Subject: [PATCH] Fix diff highlights (#38384) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Per https://github.com/zed-industries/zed/discussions/23371#discussioncomment-13533635, the issue is not new and I don't know how to solve the problem more holistically yet. All of the native themes don't have spec for `@diff.plus` and `@diff.minus` leaving addition and deletion not being highlighted. For diff file, the most valuable highlighting comes from exactly what we're missing. Hence, I think this is worth fixing. Perhaps, the ideal fix would be standardizing and documenting captures such as `@diff.plus` and `@diff.minus` on https://zed.dev/docs/extensions/languages#syntax-highlighting for theme writers to adopt. But the existing list of captures seems to be language-agnostic so I'm not sure if that's the best way forward. Per https://github.com/the-mikedavis/tree-sitter-diff/pull/18#issuecomment-2569785346, `tree-sitter-diff`'s author prefers using `@keyword` and `@string` so that `tree-sitter highlight` can work out of the box. So it seems to be an ok choice for Zed. Another approach is just adding `@diff.plus` and `@diff.minus` to the native themes. Let me know if I should pursue this instead. Before Screenshot 2025-09-18 at 11 16 14 AM After Screenshot 2025-09-18 at 12 11
15 PM Screenshot 2025-09-18 at 12 12 14 PM Closes https://github.com/zed-industries/extensions/issues/490 Release Notes: - Fixed highlighting for addition and deletion for diff language --------- Co-authored-by: MrSubidubi --- crates/languages/src/diff/highlights.scm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/languages/src/diff/highlights.scm b/crates/languages/src/diff/highlights.scm index 70ec01aa1165b6de0a23040ff3f71a32ba9fc314..4a344389032b9ff12f7c00e42adffb00721737e1 100644 --- a/crates/languages/src/diff/highlights.scm +++ b/crates/languages/src/diff/highlights.scm @@ -3,12 +3,14 @@ [ (addition) (new_file) -] @diff.plus +] @string +;; TODO: This should eventually be `@diff.plus` with a fallback of `@string` [ (deletion) (old_file) -] @diff.minus +] @keyword +;; TODO: This should eventually be `@diff.minus` with a fallback of `@keyword` (commit) @constant @@ -18,8 +20,6 @@ "diff" @function (argument) @variable.parameter) -(filename) @string.special.path - (mode) @number ([