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 support for javascriptreact language #1906

Merged
merged 2 commits into from
Apr 1, 2022

Conversation

aminehmida
Copy link
Contributor

Trying to add support for jsx (javascriptreact) syntax and language server.
Following up on this discussion: #1899

Copy link
Member

@archseer archseer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should be able to just change the "javascript" definition to say file-types = ["js", "jsx", "mjs"]

languages.toml Outdated

[[grammar]]
name = "jsx"
source = { git = "https://github.com/tree-sitter/tree-sitter-typescript", rev = "3e897ea5925f037cfae2e551f8e6b12eec2a201a", subpath = "jsx" }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no jsx subpath and that rev doesn't exist

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Appologies, I am not very familiar with those libs

You should be able to just change the "javascript" definition to say file-types = ["js", "jsx", "mjs"]

Would that be enough to fix the issue? No need to add a dedicated section? I though I may use typescriptreact because it's compatible with javascript

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it's a bit weird, but tree-sitter-javascript supports both js and jsx, but tree-sitter-typescript requires you to build two separate grammars.

@the-mikedavis
Copy link
Member

It looks like we may need to add these queries for jsx to runtime/queries/javascript/highlights.scm: https://github.com/tree-sitter/tree-sitter-javascript/blob/fdeb68ac8d2bd5a78b943528bb68ceda3aade2eb/queries/highlights-jsx.scm. Per the book I think @tag is ok but @attribute should become @variable.other.member

@archseer
Copy link
Member

archseer commented Apr 1, 2022

Yeah we actually already include them: https://github.com/helix-editor/helix/tree/master/runtime/queries/javascript

There's a TODO or two about it in languages.toml, but they should be merged into the main highlights.scm file.

@archseer
Copy link
Member

archseer commented Apr 1, 2022

I'll do that in a follow-up

@archseer archseer merged commit d0ff2ff into helix-editor:master Apr 1, 2022
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.

None yet

3 participants