• Stars
    star
    249
  • Rank 162,987 (Top 4 %)
  • Language
    Python
  • License
    MIT License
  • Created about 3 years ago
  • Updated about 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

fortls - Fortran Language Server

alt

fortls - Fortran Language Server

PyPI PyPI - Python Version PyPi Downloads via PePy Conda GitHub License GitHub Workflow Status GitHub Workflow Status Codecov Code style: black GitHub Repo stars

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

  • 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
    • ISO_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

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.

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.

What about fortls?

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

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

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/documentHighlight Same as textDocument/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 in fortran-language-server

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.

More Repositories

1

stdlib

Fortran Standard Library
Fortran
1,066
star
2

fpm

Fortran Package Manager (fpm)
Fortran
879
star
3

fprettify

auto-formatter for modern fortran source code
Python
373
star
4

vscode-fortran-support

Fortran language support for Visual Studio Code
TypeScript
212
star
5

fortran-lang.org

(deprecated) Fortran website
HTML
130
star
6

minpack

Modernized Minpack: for solving nonlinear equations and nonlinear least squares problems
Fortran
94
star
7

test-drive

The simple testing framework
Fortran
81
star
8

setup-fortran

GitHub action to setup Fortran compiler and toolchain
Shell
75
star
9

fftpack

Double precision version of fftpack
Fortran
67
star
10

http-client

http-client offers a user-friendly, high-level API to make HTTP requests in Fortran.
Fortran
58
star
11

webpage

New Fortran webpage
Python
47
star
12

fpm-registry

Centralized registry of fpm packages
Python
36
star
13

playground

An interactive Fortran playground
JavaScript
34
star
14

fpm-docs

Documentation repository for the Fortran package manager (fpm)
Fortran
34
star
15

setup-fpm

GitHub Action to setup the Fortran Package Manager for CI on Ubuntu, MacOS and Windows.
JavaScript
29
star
16

benchmarks

Fortran benchmarks
C
19
star
17

stdlib-docs

Documentation for https://github.com/fortran-lang/stdlib
HTML
18
star
18

homebrew-fortran

Homebrew tap for Fortran tooling and libraries
Ruby
13
star
19

talks

Repository for talks and presentations about fortran-lang projects
TeX
13
star
20

stdlib-cmake-example

Integration of the Fortran standard library in CMake projects
Fortran
13
star
21

fortran-forum-article-template

Article template for the ACM Fortran Forum
Shell
9
star
22

registry

Registry for Fortran package manager
JavaScript
8
star
23

fpm-metadata

Python model for Fortran package manifests
Python
6
star
24

fpm-on-wheels

Fortran package manager on wheels
Shell
4
star
25

assets

Assets, artwork and graphics for fortran-lang
HTML
3
star
26

fpm-haskell

The legacy Haskell implementation of fpm. No longer under active development.
Haskell
2
star
27

.github

Community-wide resources and default files for Fortran-lang
2
star