1
1
# fortls - the Fortran Language Server
2
2
3
3
[ ![ PyPI Latest Release] ( https://img.shields.io/pypi/v/fortls.svg )] ( https://pypi.org/project/fortls/ )
4
- [ ![ Tests] ( https://github.com/gnikit/fortran-language-server /actions/workflows/main.yml/badge.svg )] ( https://github.com/gnikit/fortran-language-server /actions/workflows/main.yml )
4
+ [ ![ Tests] ( https://github.com/gnikit/fortls /actions/workflows/main.yml/badge.svg )] ( https://github.com/gnikit/fortls /actions/workflows/main.yml )
5
5
[ ![ Documentation] ( https://github.com/gnikit/fortls/actions/workflows/docs.yml/badge.svg )] ( https://github.com/gnikit/fortls/actions/workflows/docs.yml )
6
- [ ![ image] ( https://img.shields.io/github/license/gnikit/fortran-language-server .svg )] ( https://github.com/gnikit/fortran-language-server /blob/master/LICENSE )
6
+ [ ![ image] ( https://img.shields.io/github/license/gnikit/fortls .svg )] ( https://github.com/gnikit/fortls /blob/master/LICENSE )
7
7
[ ![ Code style: black] ( https://img.shields.io/badge/code%20style-black-000000.svg )] ( https://github.com/psf/black )
8
8
9
9
` fortls ` is an implementation of the [ Language Server Protocol] ( https://github.com/Microsoft/language-server-protocol )
@@ -23,6 +23,9 @@ This project is based on @hansec's original Language Server implementation but t
23
23
` fortls ` (this project) is now developed independently of the upstream ` hansec/fortran-language-server ` project and contains numerous bug fixes and new features
24
24
the original ` fortran-language-server ` does not.
25
25
26
+ For a complete and detailed list of the differences between the two Language Servers
27
+ see the Documentation section: [ Unique fortls features (not in fortran-language-server)] ( https://gnikit.github.io/fortls/fortls_changes.html )
28
+
26
29
The name of executable for this project has been chosen to remain ` fortls `
27
30
to allow for integration with pre-existing plugins and workflows but it is
28
31
potentially subject to change.
@@ -32,7 +35,7 @@ potentially subject to change.
32
35
- Project-wide and Document symbol detection and Renaming
33
36
- Hover support, Signature help and Auto-completion
34
37
- GoTo/Peek implementation and Find/Peek references
35
- - Symbol renaming ( ` textDocument/rename ` )
38
+ - Preprocessor support
36
39
- Documentation parsing ([ Doxygen] ( http://www.doxygen.org/ ) and
37
40
[ FORD] ( https://github.com/Fortran-FOSS-Programmers/ford ) styles)
38
41
- Access to multiple intrinsic modules and functions
@@ -61,7 +64,6 @@ potentially subject to change.
61
64
62
65
- Signature help is not available for overloaded subroutines/functions
63
66
- Diagnostics are only updated when files are saved or opened/closed
64
- - Files included for preprocessor are not parsed for Fortran objects
65
67
66
68
## Installation
67
69
@@ -71,216 +73,28 @@ pip install fortls
71
73
72
74
## Settings
73
75
74
- The following global settings can be used when launching the language
75
- server.
76
-
77
- - ` --config ` Configuration options file (default: ` .fortls ` )
78
- - ` --nthreads ` Number of threads to use during workspace
79
- initialization (default: 4)
80
- - ` --notify_init ` Send notification message when workspace
81
- initialization is complete
82
- - ` --symbol_skip_mem ` Do not include type members in document symbol
83
- results
84
- - ` --incremental_sync ` Use incremental document synchronization
85
- - ` --autocomplete_no_prefix ` Do not filter autocomplete results by
86
- variable prefix
87
- - ` --autocomplete_no_snippets ` Do not use snippets with place holders
88
- in autocomplete results
89
- - ` --autocomplete_name_only ` Complete only the name of procedures and
90
- not the parameters
91
- - ` --lowercase_intrinsics ` Use lowercase for intrinsics and keywords
92
- in autocomplete requests
93
- - ` --use_signature_help ` Use signature help instead of snippets for
94
- subroutines/functions
95
- - ` --variable_hover ` Show hover information for variables (default:
96
- subroutines/functions only)
97
- - ` --hover_signature ` Show signature information in hover for argument
98
- (also enables '--variable_hover')
99
- - ` --preserve_keyword_order ` Display variable keywords information in
100
- original order (default: sort to consistent ordering)
101
- - ` --enable_code_actions ` Enable experimental code actions (default:
102
- false)
103
- - ` --disable_diagnostics ` Disable code diagnostics (default: false)
104
- - ` --max_line_length ` Maximum line length (default: none)
105
- - ` --max_comment_line_length ` Maximum comment line length (default:
106
- none)
107
- - ` --debug_log ` Write debug information to ` root_dir/fortls_debug.log `
108
- (requires a specified ` root_dir ` during initialization)
109
-
110
- ### Debug settings
111
-
112
- The following settings can be used to perform [ standalone debug
113
- tests] ( https://github.com/hansec/fortran-language-server/wiki ) on the
114
- fortls
115
-
116
- - ` --debug_filepath=DEBUG_FILEPATH ` File path for fortls tests
117
- - ` --debug_rootpath=DEBUG_ROOTPATH ` Root path for fortls tests
118
- - ` --debug_line=DEBUG_LINE ` Line position for fortls (1-indexed)
119
- - ` --debug_char=DEBUG_CHAR ` Character position for fortls tests (1-indexed)
120
- - ` --debug_full_result ` Print full result object instead of condensed
121
- version
122
- - ` --debug_parser ` Test source code parser on specified file
123
- - ` --debug_diagnostics ` Test diagnostic notifications for specified
124
- file
125
- - ` --debug_symbols ` Test symbol request for specified file
126
- - ` --debug_workspace_symbols=QUERY_STRING ` Test workspace/symbol
127
- request for project-wide search
128
- - ` --debug_completion ` Test completion request for specified file and
129
- position
130
- - ` --debug_signature ` Test signatureHelp request for specified file
131
- and position
132
- - ` --debug_definition ` Test definition request for specified file and
133
- position
134
- - ` --debug_hover ` Test hover request for specified file and position
135
- - ` --debug_implementation ` Test implementation request for specified
136
- file and position
137
- - ` --debug_references ` Test references request for specified file and
138
- position
139
- - ` --debug_rename=RENAME_STRING ` Test rename request for specified
140
- file and position
141
- - ` --debug_actions ` Test codeAction request for specified file and
142
- position
143
-
144
- ## Configuration
145
-
146
- Project specific settings can be specified by creating a ** options** JSON file.
147
- You can specify the location and name of the file with the ` --config ` option.
148
- By default the options file is assumed to be ` root_dir ` with the name ` .fortls ` .
149
-
150
- All command line options are also available through the ** options** file as well.
151
-
152
- - ` lowercase_intrinsics ` Use lowercase for intrinsics and keywords in
153
- autocomplete requests (default: false)
154
- - ` debug_log ` Write debug information to ` root_dir/fortls_debug.log `
155
- (default: false)
156
- - ` disable_diagnostics ` Disable diagnostics for this project only
157
- (default: false)
158
- - ` max_line_length ` Maximum line length (default: none)
159
- - ` max_comment_line_length ` Maximum comment line length (default:
160
- none)
161
- - ` incl_suffixes ` Add more Fortran extensions to be parsed by the server
162
-
163
- ## Additional settings
164
-
165
- ### Default file extensions
166
-
167
- By default all files with the suffix ` F,F77,F90,F95,F03,F08,FOR,FPP `
168
- (case-insensitive) in the ` root_dir ` directory, specified during
169
- initialization, and all its sub-directories are parsed and included in
170
- the project.
171
-
172
- ### Excluding folders and file extensions
173
-
174
- Directories and files can be excluded from the project by specifying
175
- their paths in the ` excl_paths ` variable in the options file.
176
- Paths can be absolute or relative to ` root_dir ` .
177
-
178
- Excluded directories ** will not** exclude all sub-directories.
179
- Source files with a common suffix may also be excluded using the
180
- ` excl_suffixes ` variable.
181
-
182
- > NOTE: All directory inputs fields (` excl_paths ` , ` source_dirs ` , ` include_dirs ` ) support
183
- > [ Python glob patterns] ( https://docs.python.org/3/library/glob.html ) e.g. ` /** ` , ` * ` , etc.
184
-
185
- ### Including source directories
186
-
187
- By default all source directories under ` root_dir ` are recursively included.
188
- Source file directories can also be specified manually by specifying
189
- their paths in the ` source_dirs ` variable in the configuration options file.
190
- Paths can be absolute or relative to ` root_dir ` .
191
- ` root_dir ` does not need to be specified manually as it is always included.
192
-
193
- When defining ` source_dirs ` in the configuration options filethe default behaviour (i.e. including
194
- all files in all subdirectories under ` root_dir ` ) is overriden. To include them
195
- back again one can do
196
-
197
- ``` json
198
- {
199
- "source_dirs" : [" /**" , " all" , " other" , " dirs" ]
200
- }
201
- ```
202
-
203
- ### Preprocessing
204
-
205
- ** Note:** Preprocessor support is not "complete", see below. For
206
- preprocessed files the ` fortls ` will only analyze code within
207
- preprocessor conditional regions if the conditional test can be
208
- evaluated by the server or if the region is the _ default_ path (ie. a
209
- bare ` #else ` region).
210
-
211
- ** Note:** Currently, ` #include ` statements are only used for
212
- preprocessing (ie. tracking definitions). Fortran objects defined in
213
- these files will not be processed.
214
-
215
- File suffixes for preprocessing can be controlled with the variable
216
- ` pp_suffixes ` in a workspace's configuration options file. When this variable is
217
- used _ only_ those files with the specified suffixes will be
218
- preprocessed. If an empty array is specified then _ no_ preprocessing
219
- will be performed on any files. By default, or if the variable is
220
- omitted or ` null ` , only files with upper case suffixes are preprocessed.
76
+ ` fortls ` can be configured through both the command line e.g.
77
+ ` fortls --hover_signature ` or through a Configuration json file.
78
+ The two interfaces are identical and a full list of the available options can
79
+ be found in the [ Documentation] ( https://gnikit.github.io/fortls/options.html )
80
+ or through ` fortls -h `
221
81
222
- Preprocessor definitions can be set for each project, to improve support
223
- for Fortran files using conditional compilation, using the ` pp_defs `
224
- variable in the configuration options file. Preprocessing is performed _ only_ for
225
- files where the file extension is all caps (ie. ".F90", ".F", etc.).
226
- Currently, support for preprocessing is limited to variables declared in
227
- the project's configuration options file or in the source file of interest as
228
- ` #include ` files and inheritance through ` USE ` statements are yet not
229
- supported. Variable substitution is also performed within files, but is
230
- 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 `
231
- throughout the file, not that value of ` PP_VAR2 ` .
232
-
233
- Include directories can be specified using the variable ` include_dirs `
234
- in a workspace's configuration options file. These directories are _ only_ used to
235
- search for preprocessor ` #include ` 'd files. The directory containing the
236
- file where an ` #include ` statement is encountered is always searched.
237
- File search is performed starting with the containing directory followed
238
- by the specified ` include_dirs ` specified paths, in order (left to
239
- right).
82
+ An example for a Configuration file is given below
240
83
241
84
``` json
242
85
{
243
- "source_dirs" : [" subdir1/**" , " subdir2" ],
244
- "excl_paths" : [" subdir3/**" , " subdir1/file_to_skip.F90" ],
86
+ "incremental_sync" : true ,
87
+ "lowercase_intrinsics" : true ,
88
+ "hover_signature" : true ,
89
+ "use_signature_help" : true ,
90
+ "excl_paths" : [" tests/**" , " tools/**" ],
245
91
"excl_suffixes" : [" _skip.f90" ],
246
- "pp_suffixes" : [" .f03" , " .F90" ],
247
- "pp_defs" : { "HAVE_PACKAGE" : " " },
248
- "include_dirs" : [" rel_include/dir_path" , " /abs/include/dir/path" ],
249
- "lowercase_intrinsics" : false ,
250
- "debug_log" : false
92
+ "include_dirs" : [" include/**" ],
93
+ "pp_suffixes" : [" .F90" , " .h" ],
94
+ "pp_defs" : { "HAVE_HDF5" : " " , "MPI_Comm" : " integer" }
251
95
}
252
96
```
253
97
254
- <!-- ## Editor examples (Atom)
255
-
256
- Document symbols (`textDocument/documentSymbol`):
257
-
258
- 
259
-
260
- Auto-complete (`textDocument/completion`):
261
-
262
- 
263
-
264
- Signature help (`textDocument/signatureHelp`):
265
-
266
- 
267
-
268
- Goto definition (`textDocument/definition`):
269
-
270
- 
271
-
272
- Hover (`textDocument/hover`):
273
-
274
- 
275
-
276
- Find references (`textDocument/references`):
277
-
278
- 
279
-
280
- Diagnostics:
281
-
282
-  -->
283
-
284
98
## Implemented server requests
285
99
286
100
| Request | Description |
@@ -310,9 +124,9 @@ Support the original project go [here](https://paypal.me/hansec)
310
124
311
125
## Bug reports
312
126
313
- When [ filing bugs] ( https://github.com/gnikit/fortran-language-server /issues/new )
127
+ When [ filing bugs] ( https://github.com/gnikit/fortls /issues/new )
314
128
please provide example code to reproduce the observed issue.
315
129
316
130
## License
317
131
318
- This project is made available under the [ MIT License] ( https://github.com/gnikit/fortran-language-server /blob/master /LICENSE ) .
132
+ This project is made available under the [ MIT License] ( https://github.com/gnikit/fortls /blob/dev /LICENSE ) .
0 commit comments