Fortran Language Server (fortls)

3.2.2 · active · verified Thu Apr 16

fortls is an implementation of the Language Server Protocol (LSP) for Fortran, built with Python 3.7+. It provides rich editor features like code completion, diagnostics, hover information, and symbol navigation for Fortran code. The current version is 3.2.2. It maintains an active development pace with frequent updates and major releases, like v3.0.0 in May 2024, introducing significant changes and new features.

Common errors

Warnings

Install

Imports

Quickstart

fortls is a language server and is primarily used by code editors that support the Language Server Protocol (LSP). The quickstart demonstrates how to verify the `fortls` executable is installed and accessible. For most users, integration involves installing an editor extension (e.g., 'Modern Fortran' for VS Code) which then manages `fortls` automatically.

# To run fortls as a language server, it's typically launched by a code editor.
# From the command line, you can verify its installation and basic functionality:
# Run the server directly (usually done by an LSP client):
# fortls

# Or check the version:
import subprocess

try:
    result = subprocess.run(['fortls', '--version'], capture_output=True, text=True, check=True)
    print(f"fortls version: {result.stdout.strip()}")
except FileNotFoundError:
    print("Error: 'fortls' executable not found. Ensure it's installed and in your PATH.")
except subprocess.CalledProcessError as e:
    print(f"Error running fortls: {e}\n{e.stderr}")

# To integrate with VS Code, install the 'Modern Fortran' extension.
# It will automatically prompt to install and use fortls.
# For other editors, refer to the 'Editor Integration' section in fortls documentation.

view raw JSON →