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

Highlight JSX in plain old js2-mode #528

Open
jacksonrayhamilton opened this issue Jun 4, 2019 · 8 comments
Open

Highlight JSX in plain old js2-mode #528

jacksonrayhamilton opened this issue Jun 4, 2019 · 8 comments

Comments

@jacksonrayhamilton
Copy link
Contributor

JSX highlighting is currently available only if

  • the user installs Emacs 27 and uses js-mode with js2-minor-mode enabled, or
  • the user installs rjsx-mode.

It would be nice if JSX was also highlighted when plain ol’ js2-mode is enabled.

As we decided in #523, the highlighting that js-mode does won’t be inherited by js2-mode, because js2-mode highlights code based on its AST, not with font-lock-keywords.

Therefore, should we ever parse JSX nodes and add them to the AST (as proposed in #527), then during that parsing, we should also record the locations where faces should be applied to JSX so that it’s highlighted as such. It should be highlighted like SGML, just like js-mode does it in Emacs 27. This issue proposes such an improvement to js2-mode.

@dgutov
Copy link
Collaborator

dgutov commented Jun 4, 2019

Sure. Except the current js2-mode parser doesn't read the nodes in good enough detail to do that. rjsx-mode already does that, I think simply during parsing.

So I think this issue is a subset of 527.

@glepnir
Copy link

glepnir commented Mar 8, 2020

It does seem to have good support in emacs28, but the highlighting seems to be missing.
image

@dgutov
Copy link
Collaborator

dgutov commented Mar 8, 2020

Highlighting of..?

@glepnir
Copy link

glepnir commented Mar 9, 2020

syntax highlight .open js2-mode .
image

@dgutov
Copy link
Collaborator

dgutov commented Mar 9, 2020

Hmm, yes. That's correct. js-mode is a lot more subtle in syntax highlighting.

But that's a historical thing. You can file a feature request for it to highlight more things.

@glepnir
Copy link

glepnir commented Mar 12, 2020

I use the color-indentifilers-mode with js-mode on emacs28 got a good syntax highlight
image

@jacksonrayhamilton
Copy link
Contributor Author

@taigacute, this issue is about highlighting JSX syntax (and only that syntax) in js2-mode, in the absence of other software. It’s not seeking the shortest path to a personal solution, or any alternatives or workarounds for any other scenarios.

We’re glad you found something that works for you, but this is not the place to the post it, unless it is relevant to the implementation proposed in the issue description.

@dgutov
Copy link
Collaborator

dgutov commented Mar 14, 2020

Indeed. Sorry, I also played a part in side-tracking this discussion.

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

No branches or pull requests

3 participants