-
Notifications
You must be signed in to change notification settings - Fork 588
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
[Javascript] Syntax highlighting changes #141
Comments
Please provide some examples so we can write some tests to ensure that scopes are being properly assigned. Are you certain these issues are Monokai specific? |
"$ (dollar sign) is white instead of previous red" Dollar sign should be white, it has no meaning (on its own or in a variable declaration) in JS what so ever. [Edited to be less general about statement above] |
@wbond I have only used Monokai so I can't speak for other color themes, sorry! |
@subhaze perhaps. That one was the least jarring change. I wouldn't be opposed to keeping it white since it indeed has no meaning in vanilla JS |
While the colors are different than before, I am not sure there is really any error here. From looking at the scopes, everything seems to be registered properly. Here is a similar PHP file, and it seems to use the same colors for the same elements. The one exception seems to be the |
Assuming this stemmed from my original post on the forums, (thanks @austenpayan - covered it all + more). The main one for me was nested objects being colored as strings. See the top Having |
@elzii I agree, this is the most important ^ |
while that may be true, it was quite nice when working with jQuery objects frequently. consider the following block of code: provides a nice visual indicator of what you're working with |
@elzii The yellow you are seeing in the object keys isn't an error, but is the color the syntax uses for unquoted strings. Notice how |
@wbond Ah, gotcha. In my post on the forum, perhaps I should have been more clear, I don't mean to suggest any of it is a bug. More that the changes are jarring for a significant amount of users and a quick consensus around the office was a preference for the older syntax. If it's something that can be resolved with a custom package, I'll pursue that route, just aimed at bringing them to the attention in case it was something overlooked. Thanks! |
Well, these changes fixed errors in the scopes. From what I can tell, the old syntax included lots of incorrect information. That isn't to say some of the new scopes may be incorrect also. The scopes are used by all sorts of things in Sublime Text, such as indexing, controlling what is spell-checked, the goto symbol quick panel, etc, not just the color scheme. I'm not disagreeing with you that the old color highlighting may look more pleasant. However, I believe the way forward is to create color schemes that make a pleasant blend of colors for what users want. Unfortunately this isn't the simplest thing since different languages use different mixes of various symbols. Just as an example, here is the new JS scopes and Go used with Base 16 eighties: From looking at the scopes in the JS, I think that With all of that said, rolling back to an old release of Sublime Text that has plenty of known bugs that have been fixed would be unfortunate. |
For comments on preferring the broken behavior of treating the I was so happy to see this fixed in the core package and not having to rely on third party packages to fix it. |
I didn't want to chime in, but felt it would be useful after checking out JavascriptNext (which the new JS syntax highlighting is based on). I discovered a list of node-specific keywords which are slightly annoying while working in vanilla JS. I attached a screenshot where the variable |
JavaScript syntax highlighting with base16-ocean-dark is totally hosed as well. Almost everything in this screenshot that is colored red was previously off-white (#BAC5C8), and unquoted keys in object literals are now green (the same color used for string literals). |
I think it would be handled by theme developer, because the new core engine. I don't think it's something that Sublime should fix. We should pay attention and wait for theme authors to update. I also don't like that object properties are same color as strings, but.. Notice that |
Hi, As a quick fix, I've modified local copy of Monokai Extended ( <dict>
<key>name</key>
<string>JS: Object keys</string>
<key>scope</key>
<string>punctuation.separator.key-value.js, string.unquoted.label.js</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string></string>
<key>foreground</key>
<string>#ffffff</string>
</dict>
</dict> Hope that helps. |
@ahwayakchih I believe that has always been that way. The reason is that the scope for functions is Personally, I don't think it would be an improvement to make all functions white. |
I'm also wishing I had the old JS highlighting. I understand that there are improvements to the highlighting, which is much appreciated, but not having any highlighting for jQuery makes the code much harder to read. Are there any current packages for highlighting jQuery syntax, including dollar signs? Could there be an optional jQuery highlighting baked into ST that could be turned on by the user? Or this just needs to be solved by 3rd party packages? |
@wbond I'm just not sure it is the best solution and here's why: when passing a function through a variable, it gets color of "regular" key name: var f = function f () {};
var obj = {
test: f
};
I do like that it gets color of a function in case of:
I just think that it looks a bit "messy" when different colors are used for keys in object literal, i.e., when some of the keys are white and others are green (or whatever colors are used by selected theme). Another problem is with var t2 = function test () {};
var t3 = () => 1; Please notice how |
@ahwayakchih I'm not sure what solution of mine you are referring to isn't the best. Above I was just explaining why object keys assigned functions are green. As I mentioned in a previous comment, scopes generated by syntaxes are used by all different parts of Sublime Text. The most important thing is that they are as correct as possible since it is not just color that depends on it. In some situations syntax files won't be able to apply "correct" scope since the code would need to be executed to determine variable values changes, etc. However, that doesn't mean we shouldn't apply correct scopes wherever possible. In terms of a solution, it sounds like the best course of action would be to create (or find) a color scheme that uses the colors you prefer for given language tokens. |
@wbond sorry for misunderstanding, i didn't mean "your solution", only "previous and current implementation". Is there a way to make a color scheme to use different color for The problem with |
@ahwayakchih I haven't looked at the scopes to see if there is a meta scope for an object literal. If so, you could target I'll try to get the |
@wbond i could not find object literal meta. I tried Thanks, |
fwiw, I was able to easily update sublime-monokai-extended to revert colors back to what they were before. It seems (as has been mentioned already in this thread) that the changes were a result of scopes actually being fixed and/or added. This is a good thing! thanks! |
I still couldn't understand why object properties are coloured as strings. I mean:
Why ~~ Also, quick off-topic: @wbond grats for officially being part of Sublime team now. Kudos. |
Status update: After reviewing lots of feedback and speaking with @jskinner, we are going to change object keys to NOT be scoped as unquoted strings. This feels like the correct change since object keys are really more like variable names than strings. We will also be fixing the In the process I am hoping to add a meta scope for object keys, so color scheme authors can handle keys that are function definitions how they want, as suggested by @ahsankhatri. Finally, I am going to be working on adding tests for #96 and getting that merged in to improve the JS syntax overall. |
@wbond thanks! although meta scope for object literal keys could be useful, i found a way to color them without additional scope. What would be maybe even more useful, is some additional scope for actual function name (as in: |
I've make tweaks to object key scopes in 10073d7. See the commit for the details. In addition, I merged in a bunch of improvements to JS from @ccampbell, added tests and fixed some other edge cases I encountered. These tweaks will be part of the next dev build. |
what about for string interpolation in es2015? var editor = "sublime";
`I use ${editor} as my editor of choice` |
@tantommy The commit I linked to includes the current changes that were made, which should make it possible for users to create color schemes that highlight $ as they see fit. By default, Currently the syntax does not support that feature you mentioned, although you could open an issue to add it, if you like. |
Edited my statement above about @wbond it has support via the old name/spec "literal-quasi" but is now named template literals. Giving the syntax file a glance it seems to support it pretty well aside from using the older name 'quasi'. |
@subhaze indeed, except that it uses the |
@wbond just wanted to say how much I appreciate the hard work you've done on this. makes my whole dev experience nicer. thank you! |
@nightpool The current version of JavaScript has been completely overhauled since build 3103, so highlighting will definitely look different, and many of the scopes have been corrected or improved. I'm not sure what color scheme you are using, but here is an example of that code using Base 16 eighties dark:
|
Resolution: Sublime Text downgrade 3083. (temporarily) OS X download address: https://download.sublimetext.com/Sublime%20Text%20Build%203083.dmg |
@azizarslan No, don't downgrade to 3083. Then JS will be very broken in many ways, and there are a quite a number of known bugs in 3083. There is much faster, better JS support in build 3107: https://www.sublimetext.com/3dev. Highlights include support for almost all ES6 features, plus about a 400% increase in performance. It has been rewritten almost from scratch, and is continually improving. |
3107 is a dev build and not available for unlicenced copies though. |
Add this to your prefered sublime color scheme file: <dict>
<key>name</key>
<string>STACK DAT DOUGH</string>
<key>scope</key>
<string>punctuation.dollar</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#F92672</string>
</dict>
</dict> |
The text was updated successfully, but these errors were encountered: