Skip to content

Instantly share code, notes, and snippets.

@MattDMo
Last active February 11, 2016 22:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MattDMo/d650ac9ea2060aa4eac3 to your computer and use it in GitHub Desktop.
Save MattDMo/d650ac9ea2060aa4eac3 to your computer and use it in GitHub Desktop.
Replacement Fortran - Modern.tmLanguage for Sublime Text 2
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>comment</key>
<string>Specificities of Fortran &gt;= 90</string>
<key>fileTypes</key>
<array>
<string>f90</string>
<string>F90</string>
<string>f95</string>
<string>F95</string>
<string>f03</string>
<string>F03</string>
<string>f08</string>
<string>F08</string>
<string>f</string>
</array>
<key>firstLineMatch</key>
<string>(?i)-[*]- mode: f90 -[*]-</string>
<key>keyEquivalent</key>
<string>^~F</string>
<key>name</key>
<string>Fortran - Modern</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>source.fortran</string>
</dict>
<dict>
<key>begin</key>
<string>(?x:^\s*(?i:(interface))\s+(?i:(operator|assignment))\(((\.[a-zA-Z0-9_]+\.)|[\+\-\=\/\*]+)\))</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>storage.type.function.fortran</string>
</dict>
<key>2</key>
<dict>
<key>name</key>
<string>storage.type.fortran</string>
</dict>
<key>3</key>
<dict>
<key>name</key>
<string>keyword.operator.fortran</string>
</dict>
</dict>
<key>comment</key>
<string>Interface declaration of operator/assignments</string>
<key>end</key>
<string>(?x:((?i:end))\s*((?i:interface)?))</string>
<key>endCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>keyword.other.fortran</string>
</dict>
<key>2</key>
<dict>
<key>name</key>
<string>storage.type.function.fortran</string>
</dict>
</dict>
<key>name</key>
<string>meta.function.interface.operator.fortran.modern</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>$self</string>
</dict>
</array>
</dict>
<dict>
<key>begin</key>
<string>(?x:^\s*(?i:(interface))\s+([A-Za-z_][A-Za-z0-9_]*))</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>storage.type.function.fortran</string>
</dict>
<key>2</key>
<dict>
<key>name</key>
<string>entity.name.function.fortran</string>
</dict>
</dict>
<key>comment</key>
<string>Interface declaration of function/subroutines</string>
<key>end</key>
<string>(?x:((?i:end))\s*((?i:interface)?))</string>
<key>endCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>keyword.other.fortran</string>
</dict>
<key>2</key>
<dict>
<key>name</key>
<string>storage.type.function.fortran</string>
</dict>
</dict>
<key>name</key>
<string>meta.function.interface.fortran.modern</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>$self</string>
</dict>
</array>
</dict>
<dict>
<key>begin</key>
<string>(?x:^\s*(?i:(type))\s+([a-zA-Z_][a-zA-Z0-9_]*))</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>storage.type.fortran.modern</string>
</dict>
<key>2</key>
<dict>
<key>name</key>
<string>entity.name.type.fortran.modern</string>
</dict>
</dict>
<key>comment</key>
<string>Type definition</string>
<key>end</key>
<string>(?x:((?i:end))\s*(?i:(type))?(\s+[A-Za-z_][A-Za-z0-9_]*)?)</string>
<key>endCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>keyword.other.fortran</string>
</dict>
<key>2</key>
<dict>
<key>name</key>
<string>storage.type.fortran.modern</string>
</dict>
<key>3</key>
<dict>
<key>name</key>
<string>entity.name.type.end.fortran.modern</string>
</dict>
</dict>
<key>name</key>
<string>meta.type-definition.fortran.modern</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>$self</string>
</dict>
</array>
</dict>
<dict>
<key>captures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>punctuation.definition.comment.fortran</string>
</dict>
</dict>
<key>match</key>
<string>(!-?).*$\n?</string>
<key>name</key>
<string>comment.line.exclamation.fortran.modern</string>
</dict>
<dict>
<key>comment</key>
<string>statements controling the flow of the program</string>
<key>match</key>
<string>\b(?i:(select\s+case|case(\s+default)?|end\s+select|use|(end\s+)?forall))\b</string>
<key>name</key>
<string>keyword.control.fortran.modern</string>
</dict>
<dict>
<key>comment</key>
<string>input/output instrinsics</string>
<key>match</key>
<string>\b(?i:(access|action|advance|append|apostrophe|asis|blank|delete|delim|direct|end|eor|err|exist|file|fmt|form|formatted|iolength|iostat|keep|name|named|nextrec|new|nml|no|null|number|old|opened|pad|position|quote|read|readwrite|rec|recl|replace|scratch|sequential|size|status|undefined|unformatted|unit|unknown|write|yes|zero|namelist)(?=\())</string>
<key>name</key>
<string>keyword.control.io.fortran.modern</string>
</dict>
<dict>
<key>comment</key>
<string>logical operators in symbolic format</string>
<key>match</key>
<string>\b(\=\=|\/\=|\&gt;\=|\&gt;|\&lt;|\&lt;\=)\b</string>
<key>name</key>
<string>keyword.operator.logical.fortran.modern</string>
</dict>
<dict>
<key>comment</key>
<string>operators</string>
<key>match</key>
<string>(\%|\=\&gt;)</string>
<key>name</key>
<string>keyword.operator.fortran.modern</string>
</dict>
<dict>
<key>comment</key>
<string>numeric instrinsics</string>
<key>match</key>
<string>\b(?i:(ceiling|floor|modulo)(?=\())</string>
<key>name</key>
<string>keyword.other.instrinsic.numeric.fortran.modern</string>
</dict>
<dict>
<key>comment</key>
<string>matrix/vector/array instrinsics</string>
<key>match</key>
<string>\b(?i:(allocate|allocated|deallocate)(?=\())</string>
<key>name</key>
<string>keyword.other.instrinsic.array.fortran.modern</string>
</dict>
<dict>
<key>comment</key>
<string>pointer instrinsics</string>
<key>match</key>
<string>\b(?i:(associated)(?=\())</string>
<key>name</key>
<string>keyword.other.instrinsic.pointer.fortran.modern</string>
</dict>
<dict>
<key>comment</key>
<string>programming units</string>
<key>match</key>
<string>\b(?i:((end\s*)?(interface|procedure|module)))\b</string>
<key>name</key>
<string>keyword.other.programming-units.fortran.modern</string>
</dict>
<dict>
<key>begin</key>
<string>\b(?i:(type(?=\s*\()))\b(?=.*::)</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>storage.type.fortran.modern</string>
</dict>
</dict>
<key>comment</key>
<string>Line of type specification</string>
<key>end</key>
<string>(?=!)|$</string>
<key>name</key>
<string>meta.specification.fortran.modern</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>$base</string>
</dict>
</array>
</dict>
<dict>
<key>match</key>
<string>\b(?i:(type(?=\s*\()))\b</string>
<key>name</key>
<string>storage.type.fortran.modern</string>
</dict>
<dict>
<key>match</key>
<string>\b(?i:(optional|recursive|pointer|allocatable|target|private|public))\b</string>
<key>name</key>
<string>storage.modifier.fortran.modern</string>
</dict>
</array>
<key>scopeName</key>
<string>source.fortran.modern</string>
<key>uuid</key>
<string>016CA1B6-8351-4B17-9215-29C275D5D973</string>
</dict>
</plist>
@MattDMo
Copy link
Author

MattDMo commented Feb 11, 2016

This version of Fortran - Modern.tmLanguage fixes the incorrect commenting behavior as described here. This is only for Sublime Text 2, as ST3 does not ship with a Fortran language definition.

To use, save the raw version of this file as Fortran - Modern.tmLanguage. Next, in Sublime, select Preferences → Browse Packages… to open the Packages folder in your operating system's file manager. Open the Fortran/Syntaxes folder and replace the existing file with the new one. Also, make sure you delete Fortran - Modern.tmLanguage.cache, otherwise the changes won't take effect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment