-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Allow js-mode for JavaScript layer? #4082
Comments
Whats the issues you encounter with js2-mode? AFAIK js-mode has not been maintained for the last 5 years, and is deprecated in favour for js3-mode, which is itself a fork of js2-mode. |
The biggest problem is that js2 (and from what I hear js3 as well) is that it doesn't work well with new/experimental JS. I was working on some experimental code and js2-mode completely breaks in syntax highlighting (js2-mode errors appear and things stop working) until I remove the offending new features unlike js-mode, Atom, Sublime, Vim, etc. I opened an issue but because it's experimental code it's not something that will be fixed upstream. js-mode may be outdated, but it doesn't break the way js2-mode does. Also since you mention it there could be an option to select js-mode, js2-mode, or js3-mode. |
This is because js2-mode is parsing the code you write to provide the syntax highlighting (as well as other semantic features, like refactoring and folding). 👍 for having an option to switch, but this switching also needs to do things, like removing the "Refactoring" Major Mode bindings. |
@jupl I work daily with JS, and have no issues with ES6 syntax highlighting/linting. Heres a screenshot from my emacs, it shows errors/warnings and more suggestions depending on the rules i use. |
@stormpat ES6 is fine today now that it has been finalized. However, before then when I was messing around with proposed features I experienced quirks. Here is a snippet of code that makes things fall apart when playing around with the function bind proposal that's available in Babel. const y = {}
x::y()
function x() {} |
@NervosaX You'll want to turn on You might have better luck using |
@oppenlander Hey, thanks for the tips. Unfortunately without using js2-mode (or variant), I lose my eslint support. Kind of screwed over there. #3661 seems to go over all the issues with all the modes. |
@NervosaX You can also gain things like eslint back by toggling off warnings/errors in js2-mode with js2-mode-toggle-warnings-and-errors. |
Ah, that's way better with the warnings/errors off. |
For me neither of the js[23]?-modes are even close to something I would find pleasant. js-mode is abandoned, js2-mode has no support whatsoever afaik for standard.js and js3-mode is fully incompatible with spacemacs. For the past 4 months I couldn't configure how to make the indentation actually consistent. Spacemacs is just not for javascript at all, none of core people care about javascript to the slightest. |
@ashnur Most of Spacemacs functionalities are coming from upstream packages, and most of the work on layers is done by non-core contributors. If you find upstream packages that handle javascript well and you have a solution to integrate it, PRs are welcome :-) |
<rant>
@StreakyCobra in this situation given your response I should either
Right now I am using js2-mode, all errors disabled and indentation completely broken. I know, I should write this to them, but they obviously do not care at all, so I am not trying to complain, just describing the "best case scenario" I could manage to find. I can manually toggle the error reporting, and I am fairly sure there is a way to make it permanently configured, but this, as many other "obvious" things, I don't even know where to look for to find. I tried adding various settings in I mean, it's still better than without any of these tools existing, and yeah it was worse before humans been able to control fire :D, but it still feels like a bottomless pit where I am stuck trying to climb out because got used to a number of things which are supported in a mutually exclusive way by half a dozen half-done, half-dead editors and plugins to these editors. Spacemacs is an exception in terms of how much care it's put into it, but that "care" completely ignored javascript and I get the feeling that although this ignorance comes from individual and rational decisions, it's still a result of conscious decisions. I am fairly sure, although I have no proof for this, that the situation has risen because js-people find emacs hard, and no one who actually works on spacemacs also works in anything js related. So when spacemacs was put together, the most popular stuff (js2-mode) was just copy pasted into it. In fact I am willing to bet that there isn't one single person on this planet who uses spacemacs for writing javascript with standard.js formatting style. |
@ashnur I can understand your frustration about all this. The fact is that Spacemacs is an open-source project, we can not force people to work on features if they don't want to. Sadly it doesn't seem that a lot of people are interested in javascript and can contribute on this layer, so I don't have a solution for you right now. You may try to open an issue (or PR) to start, animate and centralize a discussions about "how to improve javascript support in Spacemacs". People would be able to discuss what would be the best solution, share progression, find help for troubles, etc… I don't know if there will be people, but it's worth a try at least. |
@ashnur I write a lot of javascript in my day job, and im always using spacemacs. Take a look at ESLint, i am using it as a linter, because its very easy to customize. Basically i just disable the original checker and add ESLint to flycheck instead. It works good enough for me, so maybe you too can get the desired functionality from it. The js2-mode linter is a "ok" default, as it does not require any other tools. But i get your point, as i too was not pleased with the defaults. @StreakyCobra I would want to argue that people are indeed using spacemacs for javascript, its kind of a must if you do any kind of webdev. But maybe most are satisfied with the defaults as javascript has many styles and personal tastes of look and feel. For people doing primarily webdev there are more popular editors like Atom, and Sublime, but hey we want emacs, right? Finally, @ashnur you can customize your ESLint config or choose on of the many presets, airbnb being quite popular. Heres a blogpost on setting this up. (not spacemacs specific) |
@stormpat Ok, I don't do javascript, so I can not really know if Spacemacs is usable or not for this. But you're probably right saying people are doing some Javascript in Spacemacs. I'll let you discuss this further between javascripters ;-) |
@stormpat do you also happen to know a package that solves the indentation problem I have? Because that's the one which pushed me to comment here, and that's the one that you didn't answer. I did make the mistake of thinking that standard.js is also comma first, because apart from this one rule (and some whitespace mismatch), it's the exact same style I use, so I was referring to it constantly. It isn't so I since configured eslint for something that's close to my style. But I didn't refer to standard.js as "my problem is that i can't configure a linter package". I was using the name trying to explain that the auto indentation feature is incompatible with the style that the linter would be checking for. Simply put, I couldn't find the way how to make either js2-mode or js3-mode to indent my code the way I am used to. In the past several weeks it was so broken that I had to completely disable it, otherwise it was enforcing mixed indentation. That's quite bad I think. |
Personally i dont use comma first style indents, and i can see your frustration with js2-mode not having support for it. To get support for comma first style, you could try web-mode, and if you do write react apps have a look at react-mode it bundles with web-mode. |
you can have a look at react-layer code. Using web-mode, js2-minor and tern it works quite well and will respect your eslint style rules (never tried to configure eslint for comma first however). A problem I'm facing right now is how to allow object spread (should be available as experimental feature on eslint, but no way to make it works on js2-mode or react-mode) |
Where is all this coming from?
Object spread works in |
I am sorry, I was wrong. It is actually worked on. Too bad this does not really show unless you go to the source because for me that mode was unusable for years now.
Great. One thing from hundreds works. If I open my javascript code in it, would I have to wrestle with the editor to keep the formatting style consistent? |
When did you last file a bug about that?
To my knowledge. File issues if it doesn't.
That has been there for years.
Absolutely. Not ugly to me, at least. |
@dgutov If it works for you be happy with it. Why come and argue with me though? edit: No, really. Just because you use a style that is allowed and enabled by the available tools, doesn't mean it's "working" for everyone else too, as you can see others struggling with this problem too. |
@ashnur Indeed, the comma-first style isn't supported. But you can't really force someone to work on it by complaining. Even if you could, this particular issue is a poor venue for it; the Emacs bug tracker is the standard place to do it, although there aren't many JS developers there. Maybe you could ask on Reddit, or the IRC channel. Either way probably calls for a tone change. Asking questions like "does it allow indenting that is not ugly?" is vague and unhelpful.
What does ASI have to do with indentation? |
@dgutov I agree with you. I also think that you should change your tone. Especially after you incorrectly and wrongfully insinuated that I am trying to force people to work on what I want. That comment is a huge strawman imho. I also ask other people, this thread just became a collector of "why I dislike js2-mode". I don't want to change js2-mode though, because I believe that's not possible or at least not worthwhile. My only intent here and anywhere else I bring this up is to raise awareness that the situation is not as good as you and some others claim it to be. ASI has and indentation are related because in my experience some auto-indent, formatting algorithms expect semicolons where they shouldn't really, or if they don't expect, but work differently if there are semicolons than if there aren't. I admit, that I might be wrong, and maybe this never happened. Doesn't change the big picture though, it doesn't really matter how many times you find some detail in what I said I wrote that is not correct, it changes nothing about the fact that js2-mode formatting is seriously lacking. |
I don't believe I ever claimed comma-first indentation works in js2-mode. |
has the spread operation in incorporated into the react layer, please? e.g. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please let us know if this issue is still valid! |
Lately I've been having some issue with
js2-mode
and I was wondering if there is any way to have an option to usejs-mode
instead ofjs2-mode
for the JavaScript layer. I can switch tojs-mode
manually but it doesn't automatically set things up like Tern, Flycheck, Company, etc.The text was updated successfully, but these errors were encountered: