Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zed does not use the standard capture node and properties in injections.scm #9656

Open
1 task done
michaelfortunato opened this issue Mar 21, 2024 · 3 comments · May be fixed by #22268
Open
1 task done

Zed does not use the standard capture node and properties in injections.scm #9656

michaelfortunato opened this issue Mar 21, 2024 · 3 comments · May be fixed by #22268
Labels
bug [core label] editor Feedback for code editing, formatting, editor iterations, etc tree-sitter Syntax highlighting and tree-sitter

Comments

@michaelfortunato
Copy link

michaelfortunato commented Mar 21, 2024

Check for existing issues

  • Completed

Describe the bug / provide steps to reproduce it

Introduction

The standard capture nodes and properties for injections, documented here, are not being used by Zed to handle injection queries. Instead, Zed has been using a shorthand for these constructs, namely:

  • @language instead of @injection.language
  • @content instead of @injection.content
  • combined instead of injection.combined
  • language instead of injection.language

This means that Zed would not handle injection queries from extensions if they used the proper captures and properties. In fact, this is the case with the existing Java extension https://github.com/samuser107/zed-java-extension/blob/main/languages/java/injections.scm.

Reproduce Steps

  1. Confirm what the standard capture nodes and properties for injections by visiting https://tree-sitter.github.io/tree-sitter/syntax-highlighting#language-injection.
  2. Go to crates/languages/src/markdown/injections.scm, (also visible on github), and confirm that the captures that markdown is using does not match what is documented.
  3. Update crates/languages/src/markdown/injections.scm with the standard captures.
  4. Open a markdown file with a code block in Zed, observe that no syntax highlighting takes place.

Alternative Reproduction Step

On the other hand, if you wish to see that Zed is ignoring standard injection.scm written by extension authors,
you can do the following.

  1. Download the Java extension
  2. Open a java file in Zed and insert a comment block /* */ to trigger injection attempt.
  3. With a keen eye you can observe that injections are not taking place, which is difficult because this is a comment block, however, you can make the following updates to see more clearly what is happening.
  4. Navigate to /~Library/Application\ Support/zed/installed/extensions/java/grammars/java/injections.scm
  5. Update the injection file to inject a more colorful language, like "python" in for comment_block.
  6. Add some python code in the comment block in your java file in zed, observe no highlighting.
  7. Optional, if you wish to see that the only issue is a small rename, update the injections.scm file in the java extension to match the shorthand captures and properties that zed uses for injections.

PR:

I currently have a PR up #9654, which makes zed use the standard captures, updates the injections.scm files, and updates all tests which reference injection queries (as many as I could grep) to test for the standard captures and props.

Environment

Zed: v0.129.0 (Zed Dev)
OS: macOS 13.4.1
Memory: 32 GiB
Architecture: aarch64

If applicable, add mockups / screenshots to help explain present your vision of the feature

No response

If applicable, attach your ~/Library/Logs/Zed/Zed.log file to this issue.

No response

@michaelfortunato michaelfortunato added admin read Pending admin review bug [core label] triage Maintainer needs to classify the issue labels Mar 21, 2024
@Moshyfawn Moshyfawn added editor Feedback for code editing, formatting, editor iterations, etc and removed triage Maintainer needs to classify the issue labels Mar 21, 2024
@michaelfortunato michaelfortunato changed the title Zed does not use the standard capture node and predicates in injections.scm Zed does not use the standard capture node and properties in injections.scm Mar 21, 2024
@JosephTLyons JosephTLyons removed the admin read Pending admin review label Mar 26, 2024
Copy link

Hi there! 👋
We're working to clean up our issue tracker by closing older issues that might not be relevant anymore. Are you able to reproduce this issue in the latest version of Zed? If so, please let us know by commenting on this issue and we will keep it open; otherwise, we'll close it in a week. Feel free to open a new issue if you're seeing this message after the issue has been closed.
Thanks for your help!

@github-actions github-actions bot added the stale Label used by `stale` action label Sep 24, 2024
@notpeter notpeter added the tree-sitter Syntax highlighting and tree-sitter label Sep 24, 2024
@github-actions github-actions bot removed the stale Label used by `stale` action label Oct 1, 2024
@uncenter
Copy link
Contributor

uncenter commented Nov 27, 2024

Is there any interest from the Zed team in making these changes? Frustrating to support multiple editors and have to change injections queries every update to match what Zed does here

@uncenter
Copy link
Contributor

Ah sorry I see there was a PR. I'll look into reviving it with that backwards compatibility as mentioned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug [core label] editor Feedback for code editing, formatting, editor iterations, etc tree-sitter Syntax highlighting and tree-sitter
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants