All Projects → JHenneberg → Guide_VSCode-fortran

JHenneberg / Guide_VSCode-fortran

Licence: other
A comprehensive guide on how to set up a complete development environment for Fortran in Visual Studio Code.

Programming Languages

fortran
972 projects

Projects that are alternatives of or similar to Guide VSCode-fortran

Juggernaut
The unstoppable programmers editor written in Rust and Javascript
Stars: ✭ 28 (-34.88%)
Mutual labels:  ide
vscode
The Visual Studio Code Extension for the Erlang Language Server
Stars: ✭ 62 (+44.19%)
Mutual labels:  ide
AndroidStudio-ChineseLanguagePackage
AndroidStudio 中文汉化包
Stars: ✭ 48 (+11.63%)
Mutual labels:  ide
DIV
Reconstrucción y posible fork de DIV Games Studio 2.0
Stars: ✭ 41 (-4.65%)
Mutual labels:  ide
intellij-zig
The IntelliJ IDEA plugin for the Zig programming language ┗😃┛ ┏😃┓ ┗😃┛ ┏😃┓
Stars: ✭ 85 (+97.67%)
Mutual labels:  ide
CoSy
CoSy APL NoteComputing environment in open x86 Reva Forth
Stars: ✭ 33 (-23.26%)
Mutual labels:  ide
vim
个人私用的vim配置
Stars: ✭ 12 (-72.09%)
Mutual labels:  ide
icecoder
ICEcoder - Web IDE and editor for REDAXO CMS
Stars: ✭ 21 (-51.16%)
Mutual labels:  ide
vscode-liquid
💧Liquid language support for VS Code
Stars: ✭ 137 (+218.6%)
Mutual labels:  ide
Neovim-Studio
Neovim turned full-blown IDE
Stars: ✭ 30 (-30.23%)
Mutual labels:  ide
telenium
Automation for Kivy Application
Stars: ✭ 56 (+30.23%)
Mutual labels:  ide
DSTEd
This Editor is deprecated, please use Version 2.0:
Stars: ✭ 53 (+23.26%)
Mutual labels:  ide
AppleScript-IDEA
AppleScript support for IntelliJ IDEs
Stars: ✭ 21 (-51.16%)
Mutual labels:  ide
amake
A very simple Arduino command line interface for linux
Stars: ✭ 35 (-18.6%)
Mutual labels:  ide
react-monacoeditor
Monaco Editor component for React.
Stars: ✭ 191 (+344.19%)
Mutual labels:  ide
stack-editor
[Deprecated, prefer calcit-editor]
Stars: ✭ 93 (+116.28%)
Mutual labels:  ide
eclipse
Eclipse For Bazel (deprecated, see https://github.com/salesforce/bazel-eclipse instead)
Stars: ✭ 31 (-27.91%)
Mutual labels:  ide
openroberta-lab
The programming environment »Open Roberta Lab« by Fraunhofer IAIS enables children and adolescents to program robots. A variety of different programming blocks are provided to program motors and sensors of the robot. Open Roberta Lab uses an approach of graphical programming so that beginners can seamlessly start coding. As a cloud-based applica…
Stars: ✭ 98 (+127.91%)
Mutual labels:  ide
android-studio-plugin
Integrate your Android project with Crowdin
Stars: ✭ 52 (+20.93%)
Mutual labels:  ide
arduino
required (and optional) source files for the Arduino development environment, specifically the hardware/arduino sub-directory, to support xmega processors
Stars: ✭ 18 (-58.14%)
Mutual labels:  ide

Introduction

Fortran is not well supported by a lot of IDEs. Microsoft Visual Studio has syntax highlighting but missing a lot of great features, when it comes to auto completion, signature help, find and peek references. Visual Studio Code in comparison has some great extensions and is running on MacOs, Linux and Windows.

This small Guide should help you to setup a full development environment for Fortran.

Visual Studio Code

Editor Rulers

If you are working with Fortran in the fixed-column format it is useful to setup rulers at the relevant columns. Add this to your settings.json:

"[FortranFixedForm]": {
    "editor.rulers": [
            {
                "column": 72,
                "color": "#E06C75"
            },
            {
                "column": 6,
                "color": "#E06C75"
            }
        ]
},

Cursive italics and Ligature

Some might like this and some wont: Using cursive italics and programming symbol ligatures.

code snippet

  1. Download the font 'Victor Mono' from here: https://github.com/rubjo/victor-mono or here https://rubjo.github.io/victor-mono/

  2. Activate font ligatures and select the font:

    "editor.fontLigatures": true,
    "editor.fontFamily": "Victor Mono, Consolas, 'Courier New', monospace",
  3. In the standard settings for fortran syntax highlighting nothing more then paramter are italic and therefore then cursive. You can customize this quite easy:

    "editor.tokenColorCustomizations": {
         "textMateRules": [
             {
                 "name": "comment",
                 "scope": [
                     "comment",
                     "constant.language.logical",
                     "keyword.logical",
                     "variable.parameter.dummy-variable.fortran.modern",
                     "string.quoted.single.fortran",
                     "string.quoted.double.fortran",
                     "support.function.intrinsic.fortran"
                 ],
                 "settings": {
                     "fontStyle": "italic"
                 }
             },
             {
                 "name": "comment",
                 "scope": [
                     "variable.parameter.fortran"
                 ],
                 "settings": {
                     "fontStyle": ""
                 }
             }
         ]
    }

    To find out the scope you can type in the command palette (ctrl + shift + p): Developer: Inspect Editor Tokens and Scopes and hover over your source code.

Visual Studio Code Extensions

There are some extensions that are very useful. Modern Fortran can be used for syntax highlighting and snippets. For features like Signature help or GoTo/Peek definition and much more fortls should be installed.

Modern Fortran

Overview

Language Server Integration

Symbol functionality and hover information is also provided by Modern Fortran when the fortran language server fortls is installed which is written in python.

Requirements

  1. Install python
  2. Install pip
  3. Install fortls

Settings

To setup fortls a file named .fortls is needed in your workspace in Visual Studio Code. It is written in JSON. Example .fortls:

{
  "mod_dirs": [
    "src",
    "ins"
  ],
  "excl_paths": ["src/Debug", "src/Release"],
  "excl_suffixes": [".u2d", ".vfproj", ".sln", ".txt"],
  "lowercase_intrinsics": false,
  "debug_log": false
}

Build & Debug

In general you have to define a tasks.json for the build and link process and a launch.json to start to debug.

Also have a look at: https://code.visualstudio.com/docs/editor/debugging

Install compiler

  • Windows: gfortran via MinGW for example
  • Linux: sudo apt-get install gfortran, sudo pacman -S gcc-fortran
  • OSX:

Create launch.json:

{
  "version": "2.0.0",
  "configurations": [
    {
      "name": "Debug Fortran & build",
      "type": "cppdbg",
      "request": "launch",
      "targetArchitecture": "x86",
      "program": "${workspaceRoot}\\${fileBasenameNoExtension}.exe",
      "miDebuggerPath": "gdb.exe",
      "args": [],
      "stopAtEntry": false,
      "cwd": "${workspaceRoot}",
      "externalConsole": true,
      "preLaunchTask": "build_gfortran"
    }
  ]
}

Create tasks.json

The gfortran compiler should be accessible via the command line.

Create tasks.json:

{
  "version": "2.0.0",
  "_runner": "terminal",
  "tasks":[
    {
      "label": "build_gfortran",
      "type": "shell",
      "windows": {
        "command": "gfortran"
      },
      "linux": {
        "command": "gfortran"
      },
      "osx": {
        "command": "gfortran"
      },
      "args": [
        "-g",
        "${file}",
        "-o",
        "${workspaceRoot}\\${fileBasenameNoExtension}.exe"
      ]
    }
  ],
}

Debugging

Click on the debug symbol in Visual Studio Code, choose the debug configuration and press start.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].