Skip to content

Conversation

@uncenter
Copy link

@uncenter uncenter commented Dec 9, 2024

Brings over the improvements made downstream: nvim-treesitter/nvim-treesitter#6619.

@the-mikedavis
Copy link
Collaborator

I'd like to keep the highlights query in this repo simple so that it can be used with tree-sitter-cli's highlight command (which only uses this set of captures by default: https://github.com/tree-sitter/tree-sitter/blob/2c064039c7f790c47c1fefe32a85bee756e957ac/cli/src/highlight.rs#L161-L186).

Instead we could add some comments to the top of this file linking to neovim's and others' queries

@uncenter
Copy link
Author

uncenter commented Jan 3, 2025

Can it not be used if any captures are unknown? I would assume tree-sitter highlight would ignore those captures but still work?

@the-mikedavis
Copy link
Collaborator

Unknown captures won't cause an error, they just won't highlight the text at all. So diff.plus and diff.minus for example won't cause any highlighting

@uncenter
Copy link
Author

uncenter commented Jan 3, 2025

Gotcha.

@uncenter uncenter closed this Jan 3, 2025
the-mikedavis added a commit that referenced this pull request Jan 5, 2025
MrSubidubi added a commit to zed-industries/zed that referenced this pull request Nov 20, 2025
Per
#23371 (reply in thread),
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
tree-sitter-grammars/tree-sitter-diff#18 (comment),
`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
<img width="668" height="328" alt="Screenshot 2025-09-18 at 11 16 14 AM"
src="https://github.com/user-attachments/assets/d9a5b3b5-b9ef-4e74-883f-831630fb431e"
/>

After
<img width="1011" height="404" alt="Screenshot 2025-09-18 at 12 11
15 PM"
src="https://github.com/user-attachments/assets/9cf453c0-30df-4d17-99e9-f2297865f12a"
/>
<img width="915" height="448" alt="Screenshot 2025-09-18 at 12 12 14 PM"
src="https://github.com/user-attachments/assets/9e7438a6-9009-4136-b841-1f8e1356bc9b"
/>



Closes zed-industries/extensions#490


Release Notes:
- Fixed highlighting for addition and deletion for diff language

---------

Co-authored-by: MrSubidubi <finn@zed.dev>
mikayla-maki pushed a commit to zed-industries/zed that referenced this pull request Nov 20, 2025
Per
#23371 (reply in thread),
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
tree-sitter-grammars/tree-sitter-diff#18 (comment),
`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
<img width="668" height="328" alt="Screenshot 2025-09-18 at 11 16 14 AM"
src="https://github.com/user-attachments/assets/d9a5b3b5-b9ef-4e74-883f-831630fb431e"
/>

After
<img width="1011" height="404" alt="Screenshot 2025-09-18 at 12 11
15 PM"
src="https://github.com/user-attachments/assets/9cf453c0-30df-4d17-99e9-f2297865f12a"
/>
<img width="915" height="448" alt="Screenshot 2025-09-18 at 12 12 14 PM"
src="https://github.com/user-attachments/assets/9e7438a6-9009-4136-b841-1f8e1356bc9b"
/>



Closes zed-industries/extensions#490


Release Notes:
- Fixed highlighting for addition and deletion for diff language

---------

Co-authored-by: MrSubidubi <finn@zed.dev>
11happy pushed a commit to 11happy/zed that referenced this pull request Dec 1, 2025
Per
zed-industries#23371 (reply in thread),
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
tree-sitter-grammars/tree-sitter-diff#18 (comment),
`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
<img width="668" height="328" alt="Screenshot 2025-09-18 at 11 16 14 AM"
src="https://github.com/user-attachments/assets/d9a5b3b5-b9ef-4e74-883f-831630fb431e"
/>

After
<img width="1011" height="404" alt="Screenshot 2025-09-18 at 12 11
15 PM"
src="https://github.com/user-attachments/assets/9cf453c0-30df-4d17-99e9-f2297865f12a"
/>
<img width="915" height="448" alt="Screenshot 2025-09-18 at 12 12 14 PM"
src="https://github.com/user-attachments/assets/9e7438a6-9009-4136-b841-1f8e1356bc9b"
/>



Closes zed-industries/extensions#490


Release Notes:
- Fixed highlighting for addition and deletion for diff language

---------

Co-authored-by: MrSubidubi <finn@zed.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants