Sublime Forum

Build 3114 - syntax highlighting

#1

Since the last update to the syntax highlighting, everywhere I write PHP directly in a HTML element tag or JavaScript, it breaks the highlighting of the following code turning it into white.

Attached I send you some print screens with the conflict occurring and how it becomes when I remove the PHP code.

0 Likes

#2

That bug happened to me in previous ST builds so i guess it’s not a new bug, the problem could be in the regex matching of the syntax highlighting file, but you can’t do anything to fix it, i guess, Sublime Text Developer must fix it.

0 Likes

#3

Python syntax highlighting is also … different. Docstrings used to be yellow like regular strings with the Monokai color scheme. Now they’re highlighted like regular comments, and really difficult to see. Also, self is highlighted when used in code, not sure if that’s intentional or not, but it was never highlighted before.

1 Like

#4

This is intended and in line with all other languages that support “documentation blocks” (which are usually just specially formatted block comments).

0 Likes

Python syntax highlighting for docstrings
#5

 
You can add some custom coloring per scope in your active .tmTheme file:

 

<dict>
	<key>name</key>
	<string>__Scope_Alias_Goes_Here__</string>
	<key>scope</key>
	<string>__Scope_Goes_Here__</string>
	<key>settings</key>
	<dict>
		<key>foreground</key>
		<string>__#RRGGBB_Value_Goes_Here__</string>
	</dict>
</dict>
0 Likes

#6

+1
PHP syntax highlighting is also broken

0 Likes

#7

The python syntax highlighting as also broken in regards the using the \ for line termination. Anyone have any ideas as to how to fix/disable this? (Not sure if it’s intended or a bug)

0 Likes

#8

This will be fixed in the next dev build. The fix is provided in https://github.com/sublimehq/Packages/pull/397.

0 Likes

#9

I posted this on another thread, but I wanted to make sure that it is here as well. This thread is one of the top search results for exactly what you’re asking about. The answer below about using the XML configuration file is a bit dated. Here is an updated set of instructions for setting the highlighting back to what you expect (or to change it to something totally different, if that’s what you like).

Instructions

If one wants to change this behavior without digging into and modifying the default syntax and color scheme, just customize the color scheme. Sublime has its own configuration file and syntax for that. No need to use .tmTheme. Just go to the Sublime Text menu and select Preferences then “Customize Color Scheme”. This reveals an editor showing the default settings for the color scheme on the left and an empty user color scheme on the right.

To change how docstrings are highlighted, just add an entry to the list of rules. The following will change the docstrings to look like all other strings. Some people prefer this. You can also change the color that it uses by looking at the list of available colors in variables in the default color scheme. You may pick any of those colors to suit you. If you don’t like those colors, you can add a new color to the user color scheme variables. You would then choose a variable name that is not already used and then define a color there. That variable name would then be entered in the foreground field of your custom rule.

    "rules":
    [
        {
            "name": "Docstrings",
            "scope": "comment.block.documentation.python",
            "foreground": "var(yellow)"
        }
    ]

Note: I am using Monokai color scheme in this example, but you can use whichever one you like, the variable you use in the foreground field may then be different.

To access the default syntax definitions, open the command palette, and run “View Package File”. In the next popup, type “Python/” to view the contents of the default Python package. You will see “Python/Python-sublime-syntax” listed. Select it and you will then have the file with all the scopes that you need open in a new tab. (Updated from previous; thanks @FichteFoll)

Middle Ground

If you want to have docstrings that are still “commenty” but also different than other comments, I add a new color called grellow to the user variables like so.

    "variables":
    {
        "grellow": "hsl(60, 60%, 30%)"
    },

You would then change the foreground field in the rules definition to var(grellow).

0 Likes