Sublime Forum

Sublime Text 4 - Monokai Ruby class/def are now blue and italics?

#1

Hey there!

I just accepted Sublime Text’s prompt to download a new version. Turns it out was Sublime Text 4. Now all of my (Monokai theme) Ruby ‘class’ and ‘def’ have been changed to blue (they used to be red). In addition, they are now in italics.

Anyone have any clue why this happened, or how? I’m assuming it was a side effect/bug? Or a change for a different language that ended up affecting Ruby?

1 Like

ST4: Variable names in JS files now the same colour as the background
#3

Figured this out (by guess and check). Go to Sublime Text -> Preferences -> Customize Color scheme, and modify the ‘Storage type’ rule as follows (change to red2 and remove italics):

{
	"variables":
	{
	},
	"globals":
	{
	},
	"rules":
	[
		{
      "name": "Storage type",
      "scope": "storage.type",
      "foreground": "var(red2)"
    },
	]
}

Anyone who has any insight on what this ‘Storage type’ means and why it got changed in the ST4 update, if you could comment here, that would be appreciated. Any Ruby developer who upgrades to ST4 and uses Monokai is going to be wondering what the heck happened to their code syntax colors.

Cheers!

0 Likes

#4

Alright - so, this “fix” also turns javascript function calls red. Which used to be blue.

Any help here from someone on the Sublime Text team (or an official fix) would be greatly appreciated!

1 Like

#5

Also. Inline HTML styles are messed up too. For example:

<div style='margin-top: 21px;'>

The ‘px’ is also blue and in italics.

1 Like

#6

Syntaxes in general have received overhauls to allow for better scoping and newer scoping rules, which allows for more comprehensive syntax highlighting, among other things.

As such, depending on your color scheme and it’s rules, things may look different than they did before. However, as you noted above you can augment your color scheme to make everything appear as you would like it to.

1 Like

#7

I also mentioned this for Ruby a long time ago in the beta phase in the discord. The answer (iirc) was more or less that Monokai would be required to be reworked heavily on many points (cause it is old) but since this would change/break other things and in regard of the huge user base of it (cause it was the default color scheme for so long) it was not changed.
But yes, ruby syntax changes “hit” by the edges of monokai.

I hope that the ruby syntax will be reworked some time (by someone who is smarter than me in regards of how to do it correctly) to allow it to also determine start and end of classes/methods/blocks etc. Ruby is just a bit to magical to easly do this (as any Ruby dev knows ;)) .

That being said, I generally moved away from Monokai.

1 Like

#8

As mentioned above, some scope names in syntaxes were changed and made more consistent over different languages. This included a change from storage.type.* scopes which were used for declaration keywords in many languages like Python, JavaScript, … to keyword.declaration.*. To preserve the original highlighting style in color schemes for those keywords, new ST builds use the style for the storage.type scopes, if there is a rule for those in the color scheme, but no rule for keyword.declaration. This is the case for Monokai.

Now here comes the culprit: Ruby seems to have used keyword.control.* for these keywords in ST3, so unlike in most other languages they were already red in Monokai.

A similar thing happens for the CSS units, which used keyword.other.unit before, but are now constant.numeric.suffix.

You should use the following customization for Monokai to restore the old styles:

{
    "rules":
    [
        {
            "scope": "source.ruby keyword.declaration, constant.numeric.suffix.css",
            "foreground": "var(red2)",
            "font_style": ""
        },
    ]
}

If you want red declaration keywords for other syntaxes too (unlike in ST3), you could add the scopes keyword.declaration.function, keyword.declaration.class to the scope selector.

5 Likes

#9

@jwortmann - Thank you so much for the real solution here! Cheers!

1 Like

#10

Same Problem

0 Likes

#11
1 Like

#12

Try Theme - Monokai Pro

0 Likes