Skip to main content

FORTRAN Language Server for the Language Server Protocol

Project description

https://travis-ci.org/hansec/fortran-language-server.svg?branch=master https://ci.appveyor.com/api/projects/status/github/hansec/fortran-language-server?branch=master&svg=true https://img.shields.io/github/license/hansec/fortran-language-server.svg

A Fortran implementation of the Language Server Protocol using Python (2.7+ or 3.0+).

Editor extensions using this language server to provide autocomplete and other IDE-like functionality are available for Atom, Visual Studio Code, Visual Studio, (Neo)vim, and Emacs.

Language Server Features

Document Symbols:

https://raw.githubusercontent.com/hansec/fortran-language-server/master/images/fortls_outline.png

Auto Completion:

https://raw.githubusercontent.com/hansec/fortran-language-server/master/images/fortls_autocomplete.gif

Signature Help:

Note: Not available for overloaded subroutines/functions.

https://raw.githubusercontent.com/hansec/fortran-language-server/master/images/fortls_sigHelp.gif

Go to definition:

https://raw.githubusercontent.com/hansec/fortran-language-server/master/images/fortls_gotodef.gif

Hover:

https://raw.githubusercontent.com/hansec/fortran-language-server/master/images/fortls_hover.gif

Find references:

Note: Currently not supported for member variables/procedures of user-defined types.

https://raw.githubusercontent.com/hansec/fortran-language-server/master/images/fortls_refs.png

Diagnostics:

  • Multiple use of the same variable name

  • Unknown module in USE statement

  • Variable masking definition from parent scope

  • Unclosed blocks/scopes

  • Invalid scope nesting

Note: Diagnostics are only updated when files are saved or opened/closed

https://raw.githubusercontent.com/hansec/fortran-language-server/master/images/fortls_diag.png

Installation

pip install fortran-language-server

Language server settings

The following global settings can be used when launching the language server.

  • --symbol_skip_mem Do not include type members in document symbol results

  • --incremental_sync Use incremental document synchronization

  • --autocomplete_no_prefix Do not filter autocomplete results by variable prefix

  • --lowercase_intrinsics Use lowercase for intrinsics and keywords in autocomplete requests

  • --use_signature_help Use signature help instead of snippets for subroutines/functions

  • --variable_hover Show hover information for variables (default: subroutines/functions only)

  • --debug_log Write debug information to root_dir/fortls_debug.log (requires a specified root_dir during initialization)

Debug settings:

The following settings can be used to perform standalone debug tests on the language server.

  • --debug_filepath=DEBUG_FILEPATH File path for language server tests

  • --debug_rootpath=DEBUG_ROOTPATH Root path for language server tests

  • --debug_line=DEBUG_FILEPATH Line position for language server tests (1-indexed)

  • --debug_char=DEBUG_ROOTPATH Character position for language server tests (1-indexed)

  • --debug_parser Test source code parser on specified file

  • --debug_diagnostics Test diagnostic notifications for specified file

  • --debug_symbols Test symbol request for specified file

  • --debug_workspace_symbols=QUERY_STRING Test workspace/symbol request for project-wide search

  • --debug_completion Test completion request for specified file and position

  • --debug_signature Test signatureHelp request for specified file and position

  • --debug_definition Test definition request for specified file and position

  • --debug_hover Test hover request for specified file and position

  • --debug_references Test references request for specified file and position

Configuration

Project specific settings can be specified by placing a JSON file named .fortls (example below) in the root_dir directory.

  • lowercase_intrinsics Use lowercase for intrinsics and keywords in autocomplete requests (default: false)

  • debug_log Write debug information to root_dir/fortls_debug.log (default: false)

Setup module search paths:

By default all files with the suffix F,F77,F90,F95,F03,F08,FOR,FPP (case-insensitive) in the root_dir directory, specified during initialization, and all its sub-directories are parsed and included in the project.

Directories and files can be excluded from the project by specifying their paths (relative to root_dir) in the excl_paths variable in the .fortls file. Excluded directories also exclude all sub-directories. Source files with a common suffix may also be excluded using the excl_suffixes variable.

Module directories can also be specified manually by specifying their paths (relative to root_dir) in the mod_dirs variable in the .fortls file. When mod_dirs is specified directories are not added recursively, so any nested sub directories must be explicitly listed. However, root_dir does not need to be specified manually as it is always included.

Preprocessor definitions:

Preprocessor definitions can be set for each project, to improve support for Fortran files using conditional compilation, using the pp_defs variable in the .fortls file. Preprocessing is performed _only_ for files where the file extension is all caps (ie. “.F90”, “.F”, etc.). Currently, support for preprocessing is limited to variables declared in the project’s .fortls file or in the source file of interest as #include files and inheritance through USE statements are yet not supported. Variable substitution is also performed within files, but is currently limited to non-recursive cases. For example, #define PP_VAR1 PP_VAR2 will cause PP_VAR1 to be replaced with the text PP_VAR2 throughout the file, not that value of PP_VAR2.

Note: The language server will only analyze code within preprocessor conditional regions if the conditional test can be evaluated by the server or if the region is the default path (ie. a bare #else region).

{
  "mod_dirs": ["subdir1", "subdir2"],
  "excl_paths": ["subdir3", "subdir1/file_to_skip.F90"],
  "excl_suffixes": ["_skip.f90"],
  "pp_defs": {"HAVE_PACKAGE": ""},
  "lowercase_intrinsics": false,
  "debug_log": false
}

Bug reports

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

License

This project is made available under the MIT License.

Support

If you really like this package you can buy me a coffee to say thanks.

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

fortran-language-server-1.2.1.tar.gz (52.6 kB view details)

Uploaded Source

File details

Details for the file fortran-language-server-1.2.1.tar.gz.

File metadata

  • Download URL: fortran-language-server-1.2.1.tar.gz
  • Upload date:
  • Size: 52.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

File hashes

Hashes for fortran-language-server-1.2.1.tar.gz
Algorithm Hash digest
SHA256 71e677a578190518314c29f2e229ef2bbae2b621ed347fa03280b9187cc83d9d
MD5 8317d17306cdb1ec78bc080a0b82b8ff
BLAKE2b-256 4ba5b14b22a1694325204151aab6850e36c52996e7583df7d5336bea77432f6a

See more details on using hashes here.

Supported by

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