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

No syntax highliting with js2-mode and rjx-mode #8

Open
phtrivier opened this issue Apr 18, 2017 · 5 comments
Open

No syntax highliting with js2-mode and rjx-mode #8

phtrivier opened this issue Apr 18, 2017 · 5 comments
Labels

Comments

@phtrivier
Copy link

Is this minor-mode supposed to change syntax highlighting ?
I've tried several combinations:

  • js2-mode and flow-minor-mode
  • js2-mode and rjsx-mode and flow-minor-mode

The display is still using default js syntax highlithing (which looks like an error.)

Note that running flow-mode-status works as expected.

@an-sh
Copy link
Owner

an-sh commented Apr 18, 2017

No, this mode doesn't syntax/ident rules. The problem is with the js2-mode parser which requires a strict js syntax without any extensions (but in return gives 100% accurate results). Also flow supports jsx, so fixing j2-mode will be essentially replacing js2-mode Mozilla derived parser with Flow-derived one (means creating yet another one major JavaScript (jsx) mode). web-mode and plain js-mode are better to be used for flow in emacs (in my opinion). Probably there are some workarounds for using js2-mode with flow syntax, but i'm not familiar with anything sensible.

@an-sh an-sh added the question label Apr 18, 2017
@antifuchs
Copy link
Contributor

antifuchs commented May 29, 2017

So I just looked into how rjsx-mode extends js2-mode, and built a little proof-of-concept flow parsing scheme into js2-mode. It can understand type-annotated variables (with structured types, union/intersection types and a few other things, but no generic or function return types yet).

If you're interested, I can submit this as a pull request - it does result in rather pleasing-looking JS files for me now, but on the other hand, it does reach somewhat deeply into js2-mode via defadvice /:

@an-sh
Copy link
Owner

an-sh commented Jun 3, 2017

Sure, i can look at it (but not sure when i have enough time). As far as i understand this will check if the major mode is js2 mode and active, right?

@Fuco1
Copy link

Fuco1 commented Nov 29, 2017

I've took the work of @antifuchs and packaged and enhanced it here: https://github.com/Fuco1/flow-js2-mode

You might want to include a link in the readme (I link back here as well :)) for people who are looking for the syntax support/fontification.

It's a work in progress but I'd say 70% of the common usage is covered.

@an-sh
Copy link
Owner

an-sh commented Nov 29, 2017

Thanks, added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants