Comments (4)
@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.
@Qquanwei Have you tried to turn on js2-minor-mode in web-mode?
from js2-refactor.el.
@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.
from js2-refactor.el.
Related Issues (20)
- `inline-var` produces incorrect output if no semicolons are used HOT 3
- Cannot slurp the last AST node of a buffer
- js2r-contract-node-at-point not behaving as expected HOT 1
- Does js2-refactor hard-require yasnippet ? HOT 2
- Idea for js2r-extract-class-to-file
- multiple word edit failed in emacs 26.1 on archlinux (C-c C-r i-v) HOT 3
- Extract function fails inside exported functions
- extract function with a selected region extracts the whole line HOT 1
- `js2r-rename-var`: don't move cursor to the start of the symbol
- Extract function ignores jsdoc HOT 1
- move region to new file
- Moving js2-refactor under `js-emacs` HOT 6
- Toggle 'use strict' in module/defun
- How to use with js2-minor-mode? HOT 1
- js2r-inline-var doesn't work if variable is initialized with a `new` expression
- js2r-toggle-arrow-function-and-expression not working for brace-less arrow functions HOT 3
- Package not found when doing package-install HOT 2
- Work when hashbang is present HOT 1
- calling js2r-toggle-arrow-function-and-expression is not idempotent for expressions returning json HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from js2-refactor.el.