Comprehensive syntax highlighting for Fortran in Sublime Text 3.
This is a fork+update of the SublimeFortran package (see original SublimeFortran repository is at https://github.com/315234/SublimeFortran )
Just 3 easy steps!
- If you previously installed the Fortran package, you must uninstall it.
- Add the Fortran+ repository to Sublime Text's package manager:
- Install Fortran+
If you are new to Sublime Text, see the Installation Walkthrough section below for detailed instructions.
- If you previously installed the Fortran package, you must uninstall it.
- Open Command Palate (Mac: ⌘-Shift-P or Windows: Ctrl-Shift-P)
- Type 'remove package' then select the 'Package Control: Remove Package' item.
- Scroll though the list and select the Fortran item to uninstall it. (If you don't see an Fortran entry it's no big deal... it just means Fortran isn't installed which is what we were after anyway!)
- Add the Fortran+ repository to Sublime Text's package manager:
- Install Fortran+
This is a fork of SublimeFortran that fixes/handles a few things differently and in particular changes the generated parse tokens to work better with the Outline+ plugin. It also includes support for parsing F2003 derived types type-bound-procedures better as well as properly parsing the constituent 'module procedure' statements that make up a named module interface.
Note, the parsing done in SublimeFortran is rather incomplete and from the code you can tell they started ambitious but gave up half way though (no judgment hahaha it's a big task and they the resonable thing by stopping when they got it to a 'good enough' state). In particular, Fortran statements/constructs are flat parsed rather then having any real nested contexts (except for a few cases like string literals and a few of the block constructs). This makes it hard to do really detailed tag processing (for example, the parser detects 'contains' statement.. but there cannot differentiate if the contains occurred within a module, function, derive type etc.. we have little info about surrounding context for most of the parsed stuff.)
Anyway, if you see parsing bugs, or have an idea/seen another tool with a nice quality-of-life feature for Fortran, write a quick note to Adam and we can fix things up. (One thing I would like, for example, is proper 'GoTo Defintion' symbol support for module procedures.. so that the type of the arguments is parsed and known and using this info the correct overloaded module procedure is selected and you are taken to that part of the code... this is possible f we use wRapacious as the parser rather then Sublime's parsing system)
(This is fork of SublimeFortran. The original SublimeFortran repository is here. Look at this repository for more info about various fancy features (like LaTex) support within SublimeFortran)
Features:
-
Linter based on
gfortran
(requires the package SublimeLinter to work), highlights errors while you work: -
Hover over inline latex in comments to see it rendered in a popup (requires build >= 3116):
-
Hover over intrinsic functions to see documentation in a popup (requires build >= 3116):
-
Code snippets
-
Indentation rules
-
Separate syntax definitions for fixed-format and modern Fortran.
-
Based on the new sublime-syntax file format and therefore currently requires a recent beta version of Sublime Text 3 (minimum build number 3084).
Pull requests are welcome :)
-
Install Package Control
-
Open the command pallete via
ctrl+shift+p
(Win, Linux) orcmd+shift+p
(OS X) -
Choose
Package Control: Install Package
-
Choose
Fortran
-
The package will be installed and updated regularly by Package Control
-
In a terminal,
cd
into your Sublime Text Packages directory (which you can find via the menu optionPreferences → Browse Packages...
) -
Clone the repository:
git clone https://github.com/315234/SublimeFortran.git Fortran
(note the local directory name at the end of the command line) -
To update the package in future, return to the directory and run
git pull
These can be turned on or off with the following settings:
{
"fortran_disable_docs": true,
"fortran_disable_latex": true,
}
The Fixed Form Fortran syntax included in this package sets some rulers to help code indentation and show where the 72 character limit is. If you find these distracting, they can be disabled by creating a language specific settings file.
To do this, create a file called FortranFixedForm.sublime-settings
in your Packages/User/
containing the following:
{
"rulers": []
}
This package includes a linter based on SublimeLinter3. SublimeLinter user settings can be modified by selecting SublimeLinter Settings - User
from the Command Palette.
You may need to tell SublimeLinter where gfortran
is located by adding it to paths
in SublimeLinter user settings:
{
"user": {
"paths": {
"linux": [],
"osx": [
"/usr/local/bin"
],
"windows": []
},
}
}
Additional command line flags for gfortran
may be also specified:
{
"user": {
"linters": {
"gfortranfixedform": {
"@disable": false,
"args": [
"-fdefault-real-8",
"-fdefault-double-8"
],
"excludes": []
},
"gfortranmodern": {
"@disable": false,
"args": [
"-fdefault-real-8",
"-fdefault-double-8",
"-ffree-line-length-none"
],
"excludes": []
},
},
}
}
The default flags included are currently -cpp -fsyntax-only -Wall
.