zed icon indicating copy to clipboard operation
zed copied to clipboard

Use standard captures in injection queries

Open michaelfortunato opened this issue 1 year ago • 10 comments

Before this commit, zed was using captures and properties for injection queries that did not match the tree sitter documentation This was breaking the Java extension when it came to its injections.scm, and would likely break other tree-sitter extensions as authors are instructed in the tree-sitter docs to use the standard captures and properties for injection queries.

Changed

The following properties and captures used for injections have changed to be the standard ones. In particular

  • @language to @injection.language
  • @content to @injection.content
  • combined to injection.combined
  • language to injection.language

Testing

Unit tests have been updated with the standard captures as well. In particular, cd crates/language && cargo test --lib and cd crates/editor && cargo test --lib both have been updated and pass on my machine.

Release Notes:

  • Use standard captures in injection queries (#9656).

michaelfortunato avatar Mar 21 '24 17:03 michaelfortunato

We require contributors to sign our Contributor License Agreement, and we don't have @michaelfortunato on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.

cla-bot[bot] avatar Mar 21 '24 17:03 cla-bot[bot]

@cla-bot check

michaelfortunato avatar Mar 21 '24 17:03 michaelfortunato

We require contributors to sign our Contributor License Agreement, and we don't have @michaelfortunato on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.

cla-bot[bot] avatar Mar 21 '24 17:03 cla-bot[bot]

The cla-bot has been summoned, and re-checked this pull request!

cla-bot[bot] avatar Mar 21 '24 17:03 cla-bot[bot]

@cla-bot check

michaelfortunato avatar Mar 21 '24 17:03 michaelfortunato

The cla-bot has been summoned, and re-checked this pull request!

cla-bot[bot] avatar Mar 21 '24 17:03 cla-bot[bot]

Yeah, good point @michaelfortunato - no reason to do it differently from the other tree-sitter stuff.

maxbrunsfeld avatar Mar 23 '24 03:03 maxbrunsfeld

Sounds good. I had to resolve a conflict, I think it'll be able to merge now with your approval @maxbrunsfeld. Also https://github.com/zed-extensions/svelte/blob/main/languages/svelte/injections.scm will have to be updated as well.

michaelfortunato avatar Mar 23 '24 15:03 michaelfortunato

Happy to rebase the PR against main if you still want this change. If not I will close the pull request. Thanks

michaelfortunato avatar Apr 23 '24 14:04 michaelfortunato

@michaelfortunato Sorry for the delay. We now have extensions, so there are fewer languages to update in this repo, but we need to make the change in a backwards compatible way (accepting both capture names). If you are up for doing that backwards compatibility change, then we are still up for merging this.

maxbrunsfeld avatar Apr 24 '24 00:04 maxbrunsfeld

As there hasn't been movement on this PR in 3 weeks, I'm going to close it for now. We're still interested in supporting these captures, it should just be backwards compatible with our existing captures :)

mikayla-maki avatar May 18 '24 01:05 mikayla-maki