Skip to main content

fortls - Fortran Language Server

Project description

fortls - Fortran Language Server

PyPI PyPI - Python Version Tests Documentation codecov GitHub license Code style: black

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, Visual Studio, and Emacs.

fortls vs fortran-language-server

This project is based on @hansec's original Language Server 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 bug fixes and new features 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 is potentially subject to change.

Features

  • Project-wide and Document symbol detection and Renaming
  • Hover support, Signature help and Auto-completion
  • GoTo/Peek implementation and Find/Peek references
  • Preprocessor support
  • Documentation parsing (Doxygen and FORD styles)
  • Access to multiple intrinsic modules and functions
    • ISO_FORTRAN_ENV GCC 11.2.0
    • IOS_C_BINDING GCC 11.2.0
    • IEEE_EXCEPTIONS, IEEE_ARITHMETIC, IEEE_FEATURES GCC 11.2.0
    • OpenMP OMP_LIB, OMP_LIB_KINDS v5.0
    • OpenACC OPENACC, OPENACC_KINDS v3.1
  • Diagnostics
    • Multiple definitions with the same variable name
    • Variable definition masks definition from parent scope
    • Missing subroutine/function arguments
    • Unknown user-defined type used in TYPE/CLASS definition (only if visible in project)
    • Unclosed blocks/scopes
    • Invalid scope nesting
    • Unknown modules in USE statement
    • Unimplemented deferred type-bound procedures
    • Use of non-imported variables/objects in interface blocks
    • Statement placement errors (CONTAINS, IMPLICIT, IMPORT)
  • Code actions
    • Generate type-bound procedures and implementation templates for deferred procedures

Notes/Limitations

  • Signature help and hover does not handle elegantly overloaded functions i.e. interfaces

Installation

pip install fortls

Warning: it is not recommended having fortls and fortran-language-server simultaneously installed, since they use the same binary name. If you are having trouble getting fortls to work try uninstalling fortran-language-server and reinstalling fortls.

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

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

Request Description
workspace/symbol Get workspace-wide symbols
textDocument/documentSymbol Get document symbols e.g. functions, subroutines, etc.
textDocument/completion Suggested tab-completion when typing
textDocument/signatureHelp Get signature information at a given cursor position
textDocument/definition GoTo definition/Peek definition
textDocument/references Find all/Peek references
textDocument/hover Show messages and signatures upon hover
textDocument/implementation GoTo implementation/Peek implementation
textDocument/rename Rename a symbol across the workspace
textDocument/didOpen Document synchronisation upon opening
textDocument/didSave Document synchronisation upon saving
textDocument/didClose Document synchronisation upon closing
textDocument/didChange Document synchronisation upon changes to the document
textDocument/codeAction Experimental Generate code

Acknowledgements

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

Support

If you want to support this project you can do it through

Alt "Buy Me A Coffee"

Support the original project go here

Bug reports

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

License

This project is made available under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fortls-2.2.10.tar.gz (4.3 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fortls-2.2.10-py3-none-any.whl (88.7 kB view details)

Uploaded Python 3

File details

Details for the file fortls-2.2.10.tar.gz.

File metadata

  • Download URL: fortls-2.2.10.tar.gz
  • Upload date:
  • Size: 4.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.12

File hashes

Hashes for fortls-2.2.10.tar.gz
Algorithm Hash digest
SHA256 d8ac9dc33b5860013957493314e5ac81c65b645b7614369cb72ff3ad83ed14b5
MD5 eaf0428a05b57c6282e76c758f1620b6
BLAKE2b-256 682abcea0cea0bff18ba704f747c30e0fc7b06fe4cc132cc75026ad9535ebffa

See more details on using hashes here.

File details

Details for the file fortls-2.2.10-py3-none-any.whl.

File metadata

  • Download URL: fortls-2.2.10-py3-none-any.whl
  • Upload date:
  • Size: 88.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.12

File hashes

Hashes for fortls-2.2.10-py3-none-any.whl
Algorithm Hash digest
SHA256 0ba873ab45247cdbd7d65d0db25b322c81ba0c807ba4f0776547f817c0f10c8a
MD5 928da7d52409b9f8e10d33de281f278c
BLAKE2b-256 030d2886b192dee790f8839116734cefee432f64db63e4525686a7689e8d98ab

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page