Git Product home page Git Product logo

Comments (4)

NicolasPetton avatar NicolasPetton commented on September 15, 2024 5

@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)

from js2-refactor.el.

NicolasPetton avatar NicolasPetton commented on September 15, 2024

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

from js2-refactor.el.

JJPandari avatar JJPandari commented on September 15, 2024

@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?

from js2-refactor.el.

NicolasPetton avatar NicolasPetton commented on September 15, 2024

from js2-refactor.el.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.