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

Add JSDoc syntax highlighting support #7826

Merged
merged 1 commit into from
Mar 15, 2024

Conversation

rpfaeffle
Copy link
Contributor

@rpfaeffle rpfaeffle commented Feb 15, 2024

SCR-20240215-mokn

Closes #4926

Release Notes:

  • Added support for JSDoc syntax highlighting (#7224).

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Feb 15, 2024
@d1y
Copy link
Contributor

d1y commented Feb 15, 2024

Wow, Thank you

And, can you impl the regex match: https://github.com/tree-sitter/tree-sitter-javascript/blob/master/queries/injections.scm#L15-L18

@rpfaeffle
Copy link
Contributor Author

I could definitely implement that. But I would create another PR for this feature, because I think those are two different features, especially since the syntax highlighting for regex could be beneficial for multiple languages and not only JS and TS.

@d1y
Copy link
Contributor

d1y commented Feb 15, 2024

I could definitely implement that. But I would create another PR for this feature, because I think those are two different features, especially since the syntax highlighting for regex could be beneficial for multiple languages and not only JS and TS.

Yep. I'm in favor of implementing it in other PRs. and I think maybe could also help (also in another PR) to implement comment highlighting: zed-industries/extensions#523

I think this tree-sitter-comment is at least the so-called global enablement regardless of any language

image

tree-sitter: https://github.com/stsewd/tree-sitter-comment

Two different scm to reference:

Thank you~

@rpfaeffle
Copy link
Contributor Author

@SomeoneToIgnore @maxbrunsfeld @JosephTLyons

If there is an interest in implementing something like that with the use of tree-sitter, I would be happy to help.

@d1y
Copy link
Contributor

d1y commented Mar 5, 2024

Are there any issues with this PR now? Can it be merged now?

@ConradIrwin
Copy link
Collaborator

@rpfaeffle similar to the other one, it seems worth merging this as it improves javascript (which I think will remain "in-core" for a while). Would you mind rebasing on main when you get some time?

@rpfaeffle
Copy link
Contributor Author

@ConradIrwin I did a rebase of the PR. Should be good to merge.

@ConradIrwin ConradIrwin merged commit eecbafb into zed-industries:main Mar 15, 2024
8 checks passed
@ConradIrwin
Copy link
Collaborator

Thanks!

@rpfaeffle rpfaeffle deleted the jsdoc branch March 16, 2024 07:12
mrnugget pushed a commit that referenced this pull request May 3, 2024
This PR improves JSDoc injection for syntax highlighting. Now we are
only injecting JSDoc in block comments. The regex was mostly adapted
from nvim-treesitter's implementation (lua) to a rust regex.


https://github.com/nvim-treesitter/nvim-treesitter/blob/eb93c3b2fbe9ca55d70e9297d5c037880b997559/queries/ecma/injections.scm#L1-L6

**Before:**
<img width="441" alt="Screenshot 2024-04-20 at 5 51 04 AM"
src="https://github.com/zed-industries/zed/assets/20072509/8e77851d-22ad-4dc4-8e10-9ac558d3cf40">

**After:**
<img width="441" alt="Screenshot 2024-04-20 at 5 52 05 AM"
src="https://github.com/zed-industries/zed/assets/20072509/a607c219-6973-40c3-958c-44a003d008c3">

Release Notes:

- Changed detection of JSDoc to only do syntax highlighting in block
comments. Improved previous work done in #7826.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed The user has signed the Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Syntax highlighting for JSDoc
4 participants