Configuration options#

fortls can be configured through the command line interface and/or through a configuration file (by default named .fortls). The options available from the command line and through the configuration file are identical and interchangeable.

Important

Options defined in the configuration file have precedence over command line arguments.

The following sections discuss the available settings in detail.

Configuration using the command line#

fortls - Fortran Language Server

usage: fortls [options] [debug options]

Named Arguments#

-v, --version

Print server version number and exit

-c, --config

Configuration options file (default file name: “.fortlsrc”, other default supported names: .fortls.json, .fortls)

-n, --nthreads

Number of threads to use during workspace initialization (default: 4)

--notify_init

Send notification message when workspace initialization is complete

--incremental_sync

Use incremental document synchronization (beta)

--sort_keywords

Display variable keywords information, function/subroutine definitions, etc. in a consistent (sorted) manner default: no sorting, display code as is)

--disable_autoupdate

fortls automatically checks PyPi for newer version and installs them.Use this option to disable the autoupdate feature.

--preserve_keyword_order

DEPRECATED, this is now the default. To sort use sort_keywords

--debug_log

Generate debug log in project root folder

Sources file parsing options#

--source_dirs

Folders containing source files (default: set())

--incl_suffixes

Consider additional file extensions to the default (default: .F, .F77, .F90, .F95, .F03, .F08, .FOR, .FPP (lower & upper casing))

--excl_suffixes

Source file extensions to be excluded (default: set())

--excl_paths

Folders to exclude from parsing

Autocomplete options#

--autocomplete_no_prefix

Do not filter autocomplete results by variable prefix

--autocomplete_no_snippets

Do not use snippets with place holders in autocomplete results

--autocomplete_name_only

Complete only the name of procedures and not the parameters

--lowercase_intrinsics

Use lowercase for intrinsics and keywords in autocomplete requests

--use_signature_help

Use signature help instead of subroutine/function snippets. This effectively sets –autocomplete_no_snippets

Hover options#

--variable_hover

DEPRECATED: This option is always on. Show hover information for variables

--hover_signature

Show signature information in hover for arguments

--hover_language

Language used for responses to hover requests a VSCode language id (default: “fortran90”)

Diagnostic options (error swigles)#

--max_line_length

Maximum line length (default: -1)

--max_comment_line_length

Maximum comment line length (default: -1)

--disable_diagnostics

Disable diagnostics

Preprocessor options#

--pp_suffixes

File extensions to be parsed ONLY for preprocessor commands (default: all uppercase source file suffixes)

--include_dirs

Folders containing preprocessor files with extensions PP_SUFFIXES.

--pp_defs

A dictionary with additional preprocessor definitions. Preprocessor definitions are normally included via INCLUDE_DIRS

Symbols options#

--symbol_skip_mem

Do not include type members in document symbol results

CodeActions options [limited]#

--enable_code_actions

Enable experimental code actions (default: false)

All options starting with ‘–’ can also be set in a configuration file, by default named ‘.fortlsrc’, ‘.fortls.json’ or ‘.fortls’ (other names/paths can specified via -c or –config). For more details see our documentation: https://fortls.fortran-lang.org/options.html#available-options

Configuration using a file#

A configuration file is a JSONC (JSON with comments) file that contains project specific settings for fortls. By default, the Language Server will recognise 3 default names .fortlsrc, .fortls.json and .fortls (in that order) under the root_path of the project, e.g. root_path/.fortlsrc. A different configuration file name can be passed with the command line interface options --config e.g. fortls --config my_project.json.

The settings that can be specified in the configuration file are identical to the ones available through the command line interface having removed the leading -- characters. For the command line interface see Configuration using the command line.

Available options#

All the fortls settings with their default arguments can be found below

{
   "nthreads": 4,
   "notify_init": false,
   "incremental_sync": false,
   "sort_keywords": false,
   "disable_autoupdate": false,
   "debug_log": false,

   "source_dirs": ["./**"],
   "incl_suffixes": [],
   "excl_suffixes": [],
   "excl_paths": [],

   "autocomplete_no_prefix": false,
   "autocomplete_no_snippets": false,
   "autocomplete_name_only": false,
   "lowercase_intrinsics": false,
   "use_signature_help": false,

   "hover_signature": false,
   "hover_language": "fortran90",

   "max_line_length": -1,
   "max_comment_line_length": -1,
   "disable_diagnostics": false,

   "pp_suffixes": [],
   "include_dirs": [],
   "pp_defs": {},

   "symbol_skip_mem": false,

   "enable_code_actions": false
}

Sources file parsing#

source_dirs#

{
   "source_dirs": ["./**", "/external/fortran/src"]
}

By default all directories under the current project will be recursively parsed for Fortran sources. Alternatively, one can define a series of directories for fortls to look for source files

Note

glob fnmatch style patterns are allowed

incl_suffixes#

{
   "incl_suffixes": [".h", ".FYP", "inc"]
}

fortls will parse only files with incl_suffixes extensions found in source_dirs. Using the above example, fortls will match files by the file.h and file.FYP, but not file.fyp or filefyp. It will also match file.inc and fileinc but not file.inc2.

By default, incl_suffixes are defined as .F .f .F03 .f03 .F05 .f05 .F08 .f08 .F18 .f18 .F77 .f77 .F90 .f90 .F95 .f95 .FOR .for .FPP .fpp. Additional source file extensions can be defined in incl_suffixes.

Note

The default file extensions cannot be overwritten. incl_suffixes will only append to the default extensions.

excl_suffixes#

{
   "excl_suffixes": ["_tmp.f90", "_hdf5.F90"]
}

If certain files or suffixes do not need to be parsed these can be excluded by deffining excl_suffixes

excl_paths#

Entire directories can be excluded from parsing by including them in excl_paths.

Note

glob fnmatch style patterns are allowed

excl_paths uses glob patterns so if you want to exclude a directory and all its subdirectories from being parsed you should define it like so

{
   "excl_paths": ["exclude_dir/**"]
}

Preprocessor#

pp_suffixes#

{
   "pp_suffixes" : [".h", ".F90", ".fpp"]
}

By default preprocessor definitions are parsed for all Fortran source files with uppercase extensions e.g. .F90, .F, .F08, etc.. However, the default behaviour can be overriden by defining pp_defs.

include_dirs#

{
   "include_dirs": ["include", "preprocessor", "/usr/include"]
}

By default fortls will scan the project’s directories for files with extensions PP_SUFFIXES to parse for preprocessor definitions. However, if the preprocessor files are external to the project, their locations can be specific via include_dirs.

Note

glob fnmatch style patterns are allowed

Warning

Source files detected in include_dirs will not be parsed for Fortran objects unless they are also included in source_dirs.

pp_defs#

{
   "pp_defs": {
      "HAVE_PETSC": ""
      "Mat": "type(tMat)"
   }
}

Additional preprocessor definitions from what are specified in files found in include_dirs can be defined in pp_defs.

Note

Definitions in pp_defs will override definitions from include_dirs

Limitations#

  • Recursive substitution is not available e.g.

    #define VAR1 10
    #define VAR2 VAR1
    

Debug Options (command line only)#

Options for debugging language server

  • --debug_filepath DEBUG_FILEPATH File path for language server tests

  • --debug_rootpath DEBUG_ROOTPATH Root path for language server tests

  • --debug_parser Test source code parser on specified file

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

  • --debug_rename RENAME_STRING Test textDocument/rename request for specified file and position

  • --debug_actions Test textDocument/codeAction request for specified file and position

  • --debug_symbols Test textDocument/documentSymbol request for specified file

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

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

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

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

  • --debug_diagnostics Test diagnostic notifications for specified file

  • --debug_implementation Test textDocument/implementation request for specified file and position

  • --debug_workspace_symbols QUERY_STRING Test workspace/symbol request

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

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

  • --debug_full_result Print full result object instead of condensed version