Home

Awesome

alt

fortls - Fortran Language Server

Powered by NumFOCUS PyPI PyPI - Python Version PyPI - Downloads Conda GitHub License GitHub Workflow Status GitHub Workflow Status Codecov Code style: black GitHub Repo stars DOI

<!-- [<img alt="https://github.com/sponsors/gnikit" src="https://img.shields.io/static/v1?style=social&label=Sponsor&message=%E2%9D%A4&logo=GitHub&color&link=%3Curl%3E" height="30" />](https://github.com/sponsors/gnikit) [<img alt="https://paypal.me/inikit" src="https://img.shields.io/static/v1?style=social&label=Donate&message=%E2%9D%A4&logo=Paypal&color&link=%3Curl%3E" height="30" />](https://paypal.me/inikit) -->

alt

fortls is an implementation of the Language Server Protocol (LSP) for Fortran using Python (3.7+).

All code editors that support LSP can integrate with fortls see the section Editor Integration in the documentation. Some supported code editors include: Visual Studio Code, Atom, Sublime Text, (Neo)Vim, and Emacs.

Features

Notes/Limitations

Documentation

The full documentation for fortls can be found at fortls.fortran-lang.org.

Installation

PyPi

pip install fortls

Anaconda

conda install -c conda-forge fortls

for more information about the Anaconda installation see

Common installation problems

It is NOT recommended having fortls and fortran-language-server simultaneously installed, since they use the same executable name. If you are having trouble getting fortls to work try uninstalling fortran-language-server and reinstalling fortls.

With pip

pip uninstall fortran-language-server
pip install fortls --upgrade

or with Anaconda

conda uninstall fortran-language-server
conda install -c conda-forge fortls

Settings

fortls can be configured through both the command line e.g. fortls --hover_signature or through a Configuration json file. The two interfaces are identical and a full list of the available options can be found in the Documentation or through fortls -h

An example for a Configuration file is given below

{
  "incremental_sync": true,
  "lowercase_intrinsics": true,
  "hover_signature": true,
  "use_signature_help": true,
  "excl_paths": ["tests/**", "tools/**"],
  "excl_suffixes": ["_skip.f90"],
  "include_dirs": ["include/**"],
  "pp_suffixes": [".F90", ".h"],
  "pp_defs": { "HAVE_HDF5": "", "MPI_Comm": "integer" }
}

Implemented server requests

RequestDescription
workspace/symbolGet workspace-wide symbols
textDocument/documentSymbolGet document symbols e.g. functions, subroutines, etc.
textDocument/completionSuggested tab-completion when typing
textDocument/signatureHelpGet signature information at a given cursor position
textDocument/definitionGoTo definition/Peek definition
textDocument/referencesFind all/Peek references
textDocument/documentHighlightSame as textDocument/references
textDocument/hoverShow messages and signatures upon hover
textDocument/implementationGoTo implementation/Peek implementation
textDocument/renameRename a symbol across the workspace
textDocument/didOpenDocument synchronisation upon opening
textDocument/didSaveDocument synchronisation upon saving
textDocument/didCloseDocument synchronisation upon closing
textDocument/didChangeDocument synchronisation upon changes to the document
textDocument/codeActionExperimental Generate code

Future plans

fortls has reached a point where it is feature complete and stable enough to be used in many modern Fortran projects without any issues. It does however still have fundamental limitations, namely its ability to understand all Fortran syntax and semantics that has been used throughout the 65+ years of the language. The good news is that we have a plan to address this issue!

We are excited to announce that we are working on creating a new Fortran Language Server based on the actively developed LFortran compiler 🎉. The new Language Server will be able to understand all Fortran syntax, be faster, and give more accurate autocompletion, hover and diagnostic information. That means we plan on investing any future funding on creating our new language server and ultimately creating a better user experience for everyone.

<!-- Have a look at our roadmap (link) and consider contributing to our efforts (donations and contribution tasks link). -->

What about fortls?

Not to worry, fortls will continue to be here. We will keep fortls in active maintenance mode with bug fixes and new features from volunteer contributors, but otherwise we will be focusing our efforts into making the new language server using LFortran's parser a reality.

fortls vs fortran-language-server

This project was originally based on fortran-language-server LSP implementation, but the two projects have since diverged.

fortls (this project) is now developed independently of the upstream hansec/fortran-language-server project and contains numerous new features and bug fixes the original fortran-language-server does not.

For a complete and detailed list of the differences between the two Language Servers see the Documentation section: Unique fortls features (not in fortran-language-server)

The name of executable for this project has been chosen to remain fortls to allow for integration with pre-existing plugins and workflows, but it could change in the future.

Acknowledgements

This project would not have been possible without the original work of @hansec in fortran-language-server

Support

You can support Fortran-lang as a whole by donating at Fortran-lang - NumFOCUS.

Bug reports

When filing bugs please provide example code to reproduce the observed issue.

Security Policy

To report a security vulnerability please follow the instructions in our Security page.

License

This project is made available under the MIT License.