Registry / web-framework / fortls

fortls

JSON →
library3.2.2pypypi✓ verified 86d ago

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.

pip install fortls
INSTALL
IMPORT
SIG · FORTLS
F
fortls
web-frameworkpythonv3.2.2
Install
1.9s avg
Import
333ms
Disk
19MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v3.2.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.353s · 20.4MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 1.9s · import 0.313s · 21MB
19MB installed
● package 19MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

fortls
import fortls
While 'fortls' is typically run as an executable, it can be imported for programmatic interaction or testing, although this is less common for end-users.

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.
fortls --version
Debug
Known issues
breakingMajor release v3.0.0 (May 2024) introduced significant internal changes and new features, potentially affecting configurations or custom integrations that relied on older internal behaviors. Users are advised to review the changelog for detailed updates.
fix
Review the official fortls documentation and changelog on GitHub for v3.0.0 and subsequent releases. Update editor configurations if necessary. Consider clearing any old configuration files like `.fortlsrc` if encountering issues.
affects: >=3.0.0
gotchaIt is strongly NOT recommended to have both `fortls` and `fortran-language-server` installed simultaneously. They use the same executable name, leading to conflicts and unpredictable behavior.
fix
Uninstall `fortran-language-server` before installing `fortls` (e.g., `pip uninstall fortran-language-server`). If both are installed, uninstall `fortran-language-server` and then reinstall `fortls` to ensure proper setup.
affects: All versions
gotchaOn Windows, if `pip` install location is not in your system's PATH, editor integrations (like VS Code) may not find the `fortls.exe` executable.
fix
Manually add the `pip` scripts directory (e.g., `C:\Users\<username>\AppData\Local\Packages\PythonSoftwareFoundation.Python.<version>\LocalCache\local-packages\Python<version>\Scripts`) to your system's PATH environment variable, or explicitly configure the `fortls` executable path in your editor's settings (e.g., `"fortran.fortls.path": "C:\path\to\fortls.exe"` for VS Code).
affects: All versions on Windows
gotchafortls automatically checks PyPI for newer versions and attempts to update itself by default. While this ensures users generally run the latest version, it can be problematic if new versions introduce breaking changes or if a specific version needs to be pinned.
fix
To disable auto-updating, use the `--disable_autoupdate` command-line option when running `fortls`, or add `"disable_autoupdate": true` to your `.fortlsrc` configuration file.
affects: All versions with autoupdate enabled
gotchaFor large or complex Fortran projects, `fortls` initialization can take a long time and consume significant system resources (CPU and RAM), potentially leading to editor unresponsiveness or server lag.
fix
Configure `fortls` with the `--nthreads` option to limit the number of threads used during initialization (default is 4). Exclude unnecessary directories and file types from parsing using `--excl_paths` and `--excl_suffixes` in the command line or `.fortlsrc` configuration file. If possible, upgrade server hardware or test with smaller subsets of the codebase.
affects: All versions, especially with large codebases
Errors
Common errors & fixes
Error: 'fortls' executable not found.
The 'fortls' executable is not in the system's PATH environment variable, or the Python environment where it was installed is not active. This is common on Windows or when using virtual environments.
fix
Ensure `fortls` is installed in the active Python environment. Add the Python scripts directory (where `fortls.exe` is located) to your system's PATH. Alternatively, configure your editor to explicitly point to the `fortls` executable's full path.
LSP feature (e.g., hover, autocompletion) not working or showing incorrect results.
This can be caused by conflicts with the `fortran-language-server` package, an outdated `fortls` installation, or incorrect project configuration (e.g., missing source directories or preprocessor definitions).
fix
First, ensure `fortran-language-server` is uninstalled. If the issue persists, try reinstalling `fortls` (`pip install fortls --upgrade`). Verify your project's `.fortlsrc` configuration file or editor settings (e.g., `source_dirs`, `include_dirs`, `pp_defs`) correctly point to your Fortran source files and necessary preprocessor definitions. Restart your code editor after making changes.
fortls initialization never ending / taking too long and consuming excessive resources.
The language server is likely parsing a very large codebase, potentially with complex or non-standard Fortran, or it may be stuck on a particular file. This can exhaust system memory and CPU.
fix
Limit the number of threads `fortls` uses for initialization with the `--nthreads` command-line option. Configure `.fortlsrc` or command-line arguments to exclude unnecessary directories (`--excl_paths`) or file types (`--excl_suffixes`) from being parsed. If possible, identify and isolate the problematic Fortran files or directories.
Signature help and hover does not handle elegantly overloaded functions i.e. interfaces.
This is a known limitation of `fortls` due to the complexity of parsing overloaded functions in Fortran.
fix
Currently, there is no direct fix within `fortls` for this specific limitation. Users should refer to the full documentation for overloaded procedures if the basic hover/signature help is insufficient. Keep `fortls` updated, as future releases might improve support.
Upgrade
Version history
3.2.2latest on PyPI · released Mar 16, 2025
Audit
Dependencies
pythonrequiredfortls is a Python application and requires Python >= 3.7.
Agent activity
2 hits · last 30 days
node
2
Resources