Skip to content

Instantly share code, notes, and snippets.

@krisrybak
Last active July 28, 2020 15:11
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save krisrybak/ba7a9da1b80be6c913c9 to your computer and use it in GitHub Desktop.
Save krisrybak/ba7a9da1b80be6c913c9 to your computer and use it in GitHub Desktop.
Symfony Annotations highlights for Sublime3

Please make sure you use Sublime 3 first:

  • From the Sublime Tex Menu choose option About and make sure build is higher that 3xxx
  • Navigate to your Sublime text packages directory: Sublime Text Menu > Preferences > Browse Packages...
  • Copy PHP folder form Cache into Packages folder
  • Locate PHP.tmLanguage file insde PHP folder and open in for edit:
  • Inside yuor PHP.tmLanguage find: <key>php_doc</key> node and update the language file by adding the following snippet under the php_doc's patterns array:
    <dict>
      <key>match</key>
      <string>\@(Route|Template|Method|ParamConverter|Cache)\b</string>
      <key>name</key>
      <string>keyword.other.symfonyannotations.php</string>
    </dict>

Your PHP.tmLanguage file should look something like this:

<key>php_doc</key>
<dict
    <key>patterns</key>
        <array>
            .
            .
            .
		<dict>
		    <key>match</key>
		    <string>\@(Route|Template|Method|ParamConverter|Cache)\b</string>
		    <key>name</key>
		    <string>keyword.other.symfonyannotations.php</string>
		</dict>
		<dict>
		    <key>match</key>
		    <string>\@(Assert)\b</string>
		    <key>name</key>
		    <string>keyword.other.symfonyassertannotations.php</string>
		</dict>
		<dict>
		    <key>match</key>
		    <string>\@(ORM)\b</string>
		    <key>name</key>
		    <string>keyword.other.doctrineannotations.php</string>
		</dict>
		<dict>
		    <key>match</key>
		    <string>\@(Secure)\b</string>
		    <key>name</key>
		    <string>keyword.other.jmssecurityannotations.php</string>
		</dict>
       </array>
</dict>

Updating the theme files to highlight the annotations

Update your current colour theme file to include the following styles, feel free to change the highlight colour to match your theme if required:

  • Copy Color Scheme - Default folder form Cache into Packages folder and edit the Theme you use (for example: Monokai.tmTheme):
  • Add followign snipped:
		<dict>
		    <key>name</key>
		    <string>PHP: Symfony Annotations</string>
		    <key>scope</key>
		    <string>keyword.other.symfonyannotations.php</string>
		    <key>settings</key>
		        <dict>
		             <key>foreground</key>
		             <string>#EE8709</string>
		        </dict>
		</dict>
		<dict>
		    <key>name</key>
		    <string>PHP: Doctrine Annotations</string>
		    <key>scope</key>
		    <string>keyword.other.symfonyassertannotations.php</string>
		    <key>settings</key>
		        <dict>
		             <key>foreground</key>
		             <string>#ede62a</string>
		        </dict>
		</dict>
		<dict>
		    <key>name</key>
		    <string>PHP: Doctrine Annotations</string>
		    <key>scope</key>
		    <string>keyword.other.doctrineannotations.php</string>
		    <key>settings</key>
		        <dict>
		             <key>foreground</key>
		             <string>#35D693</string>
		        </dict>
		</dict>
		<dict>
		    <key>name</key>
		    <string>PHP: JMS Security Annotations</string>
		    <key>scope</key>
		    <string>keyword.other.jmssecurityannotations.php</string>
		    <key>settings</key>
		        <dict>
		             <key>foreground</key>
		             <string>#1ec932</string>
		        </dict>
		</dict>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment