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

Any plan to support web-mode #99

Closed
Qquanwei opened this issue Oct 13, 2017 · 4 comments
Closed

Any plan to support web-mode #99

Qquanwei opened this issue Oct 13, 2017 · 4 comments
Labels

Comments

@Qquanwei
Copy link

Due to js2-refactor depend on js2-mode AST, doesn't support web-mode, but I usually using web-mode to edit by jsx files and web-mode is so popular , so any plan to support web-mode ?

@NicolasPetton
Copy link
Collaborator

@Qquanwei Have you tried to turn on js2-minor-mode in web-mode?

@NicolasPetton
Copy link
Collaborator

@Qquanwei I confirm that with the following settings js2-refactor works in web-mode for javascript files:

(add-hook 'web-mode-hook #'js2-minor-mode)
(add-hook 'web-mode-hook #'js2-refactor-mode)

@JJPandari
Copy link

@NicolasPetton Great to know there's js2-minor-mode.

A little observation: I tried in a web-mode buffer, when the code is <script>function () {...}</script>, js2r says there's parse errors, when I removed the <script> </script>tags, js2-parsed-errors is nil and js2r works fine.

Thoughts on maybe-a-new-feature: The above is the most common situation when I want to use web-mode: an html or server side template file, with javascript codes wrapped in <script> tags. js2r doesn't work unless we extract the js codes for js2-mode to parse them alone, not the whole buffer. Is it a good idea to maybe have some configs like (setq js2-js-code-surrounding-tags '("<script>" "</script>")) (setq js2-js-code-matcher "<script>\\(.+\\)<\\/script>") (don't mind my elisp regex error if there's any), so users can easily use all js2 and js2r goodies in html files and so?

This feature shouldn't be too hard to implement with some with-temp-buffer thing I guess? But still a bit beyond my reach and it may fit in js2 so... Also this may not cover all server side template files like var <?=$name?> = "<?=$value?>"; (<?=$var?> is the .php file interpolation syntax) as js2 will have parse errors on them, but covering html files should still be quite a step.

Wait, should I open an issue for js2-mode?

@NicolasPetton
Copy link
Collaborator

NicolasPetton commented Apr 30, 2018 via email

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

3 participants