File: options.rst

package info (click to toggle)
fortran-language-server 3.2.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,268 kB
  • sloc: python: 9,688; f90: 1,195; fortran: 30; makefile: 28; ansic: 20
file content (236 lines) | stat: -rw-r--r-- 7,495 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
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.


.. _cmd_interface:

Configuration using the command line
------------------------------------

.. argparse::
   :module: fortls
   :func: cli
   :prog: fortls
   :nodefault:

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 :ref:`cmd_interface`.

Available options
#################

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

.. code-block:: json

   {
      "nthreads": 4,
      "notify_init": false,
      "incremental_sync": false,
      "recursion_limit": 1000,
      "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
***********

.. code-block:: json

   {
      "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
*************

.. code-block:: json

   {
      "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
*************

.. code-block:: json

   {
      "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

.. code-block:: json

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

Preprocessor
############

pp_suffixes
***********

.. code-block:: json

   {
      "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
************

.. code-block:: json

   {
      "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
*******

.. code-block:: json

   {
      "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.

   .. code-block:: cpp

      #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_preproc``                         Test preprocessor 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