1
- # Modern Fortran language support for VSCode
1
+ ![ alt ] ( assets/modern-fortran-logo.png )
2
2
3
- [ ![ GitHub Actions] ( https://github.com/krvajal /vscode-fortran-support/actions/workflows/main.yaml/badge.svg )] ( https://github.com/krvajal /vscode-fortran-support/actions )
3
+ [ ![ GitHub Actions] ( https://github.com/fortran-lang /vscode-fortran-support/actions/workflows/main.yaml/badge.svg )] ( https://github.com/fortran-lang /vscode-fortran-support/actions )
4
4
[ ![ Downloads] ( https://vsmarketplacebadge.apphb.com/downloads-short/krvajalm.linter-gfortran.svg )] ( https://marketplace.visualstudio.com/items?itemName=krvajalm.linter-gfortran )
5
5
[ ![ Installs] ( https://vsmarketplacebadge.apphb.com/installs/krvajalm.linter-gfortran.svg )] ( https://marketplace.visualstudio.com/items?itemName=krvajalm.linter-gfortran )
6
6
[ ![ VS Marketplace] ( https://vsmarketplacebadge.apphb.com/version-short/krvajalm.linter-gfortran.svg )] ( https://marketplace.visualstudio.com/items?itemName=krvajalm.linter-gfortran )
7
7
[ ![ MIT License] ( https://img.shields.io/npm/l/stack-overflow-copy-paste.svg? )] ( http://opensource.org/licenses/MIT )
8
8
9
+ ![ alt] ( assets/intro-demo.gif )
10
+
9
11
## Key Features
10
12
11
13
- Syntax highlighting (Free and Fixed forms)
12
- - Hover support
13
- - Autocompletion support
14
- - Peek/Go to definitions and references
15
- - Linting support i.e. error wiggles for ` gfortran ` , ` flang ` and ` ifort `
16
- - Symbols outline support for functions, subroutines, modules, etc.
17
- - Native support leveraging the ` fortls `
18
- - Debugger, uses Microsoft's [ C/C++ extension] ( https://github.com/Microsoft/vscode-cpptools )
14
+ - Hover support, Signature help and Auto-completion
15
+ - GoTo/Peek implementation and Find/Peek references
16
+ - Project-wide and Document symbol detection and Renaming
17
+ - Native Language Server integration with [ ` fortls ` ] ( https://github.com/gnikit/fortls )
18
+ - Linting support for ` gfortran ` , ` flang ` and ` ifort `
19
+ - Debugger [ C/C++ extension] ( https://github.com/Microsoft/vscode-cpptools )
19
20
- Formatting with [ findent] ( https://github.com/gnikit/findent-pypi ) or [ fprettify] ( https://github.com/pseewald/fprettify )
20
21
- Code snippets (more can be defined by the user [ see] ( https://code.visualstudio.com/docs/editor/userdefinedsnippets#_create-your-own-snippets ) )
21
22
22
- ![ alt] ( ./images/intro-demo.gif )
23
-
24
- ## Settings
23
+ ## Language Server integration
25
24
26
- You can control the include paths to be used by the linter with the ` fortran.linter.includePaths ` setting.
27
- The ` linter.includePaths ` should match the include requirements for your projects compilation.
25
+ The Fortran Language Server [ ` fortls ` ] ( https://github.com/gnikit/fortls ) is responsible
26
+ for providing a lot of the higher level, IDE functionality. By default,
27
+ ` Modern Fortran ` will attempt to use it for hover, autocompletion, symbols and Go to & Peeking into definitions.
28
28
29
- > NOTE: if a glob pattern is used only directories matching the pattern will be included.
29
+ Allow for ` fortls ` to be automatically installed with ` pip ` or ` Anaconda ` and
30
+ if the location where ` fortls ` is installed is not in your ` PATH ` point VS Code
31
+ to the ` fortls ` location by setting
30
32
31
- ``` jsonc
33
+ ``` json
32
34
{
33
- " fortran.linter.includePaths " : [ " /usr/include/** " , " ${workspaceFolder}/include/** " ]
35
+ "fortran.fortls.path " : " /custom/path/to/fortls "
34
36
}
35
37
```
36
38
37
- By default the ` gfortran ` executable is assumed to be found in the path. In order to use a different one or if it can't be found in the path you can point the extension to use a custom one with the ` fortran.linter.compilerPath ` setting.
39
+ For more about the Language Server's capabilities please refer to the
40
+ [ documentation] ( https://gnikit.github.io/fortls/ ) of ` fortls ` .
41
+
42
+ ## Linting
43
+
44
+ Linting allows for compiler error and warning detection while coding
45
+ without the user having to compile.
46
+
47
+ Using an invalid if expression
48
+
49
+ ![ alt] ( assets/lint-demo.gif )
50
+
51
+ Using incorrect type and rank as function argument
52
+
53
+ ![ alt] ( assets/lint-demo2.gif )
54
+
55
+ | :memo : Note |
56
+ | ------------------------------------------ |
57
+ | Save your file to generate linting results |
58
+
59
+ Linting results can be improved by providing additional options to the compiler.
60
+
61
+ ### Including directories
62
+
63
+ You can control the include paths to be used by the linter with the ` fortran.linter.includePaths ` option.
64
+
65
+ | :exclamation : Important |
66
+ | ------------------------------------------------------------------------------------------------------------------ |
67
+ | For the best linting results ` linter.includePaths ` should match the included paths for your project's compilation. |
38
68
39
69
``` jsonc
40
70
{
41
- " fortran.linter.compilerPath " : " /usr/local/bin/gfortran-11.2 "
71
+ " fortran.linter.includePaths " : [ " /usr/include/** " , " ${workspaceFolder}/include/** " ]
42
72
}
43
73
```
44
74
45
- If you want to pass extra options to the ` gfortran ` executable or override the default one, you can use the setting ` fortran.linter.extraArgs ` . Default value is ` -Wall ` (or ` -warn all ` for ifort).
75
+ | :exclamation : Important |
76
+ | -------------------------------------------------------------------------------- |
77
+ | If a glob pattern is used only directories matching the pattern will be included |
78
+
79
+ ### Additional linting options
80
+
81
+ More options can be passed to the linter via
46
82
47
83
``` jsonc
48
84
{
49
- " fortran.linter.extraArgs" : [" -Wall" ]
85
+ " fortran.linter.extraArgs" : [
86
+ " -fdefault-real-8" ,
87
+ " -fdefault-double-8" ,
88
+ " -Wunused-variable" ,
89
+ " -Wunused-dummy-argument"
90
+ ]
50
91
}
51
92
```
52
93
53
- To show the symbols in the file outline enable ` provide.symbols ` . Symbols can be
54
- served by the fortls, the built-in, both or none. By default
55
- ` fortls ` is used.
94
+ Default value is ` -Wall ` (or ` -warn all ` for ifort).
95
+
96
+ ### Changing linting compiler
97
+
98
+ By default, the linter used is ` gfortran ` , Intel's ` ifort ` and LLVM's ` flang ` are also supported.
99
+ One can use a different linter compiler via the option
56
100
57
101
``` jsonc
58
102
{
59
- " fortran.provide.symbols " : " fortls " | " Built-in " | " Both " | " Disable "
103
+ " fortran.linter.compiler " : " ifort " | " gfortran " | " flang " | " Disabled "
60
104
}
61
105
```
62
106
63
- You can also configure the case for fortran intrinsics auto-complete by using
107
+ The linter executable is assumed to be found in the ` PATH ` .
108
+ In order to use a different executable or if the executable can't be found in the ` PATH `
109
+ you can point the extension to another linter with the ` fortran.linter.compilerPath ` option.
64
110
65
111
``` jsonc
66
112
{
67
- " fortran.preferredCase " : " lowercase " | " uppercase "
113
+ " fortran.linter.compilerPath " : " /opt/oneapi/compiler/2022.0.2/linux/bin/intel64/ifort "
68
114
}
69
115
```
70
116
71
- ## Snippets
72
-
73
- This is a list of some of the snippets included, if you like to include additional snippets please let me know and I will add them.
74
-
75
- ### Program skeleton
76
-
77
- ![ program snippet] ( https://media.giphy.com/media/OYdq9BKYMOOdy/giphy.gif )
78
-
79
- #### Module skeleton
80
-
81
- ![ module snippet] ( https://media.giphy.com/media/3ohzdUNRuio5FfyF1u/giphy.gif )
82
-
83
- ## Error wiggles
84
-
85
- To trigger code validations you must save the file first.
86
-
87
117
## Debugging
88
118
119
+ ![ alt] ( assets/gdb_ani.gif )
120
+
89
121
The extension uses the debugger from Microsoft's
90
122
[ C/C++ extension] ( https://github.com/Microsoft/vscode-cpptools )
91
123
for Visual Studio Code. This allows this extension to use the full functionality
92
124
of the C/C++ extension for debugging applications:
93
- (un)conditional breaking points, expression evaluation, multi-threaded debugging,
125
+ (un)conditional breaking points, expression evaluation, multithreaded debugging,
94
126
call stack, stepping, watch window.
95
127
96
128
A minimal ` launch.json ` script, responsible for controlling the debugger, is
97
129
provided below. However, Visual Studio Code is also capable of autogenerating
98
130
a ` launch.json ` file and the configurations inside the file.
99
131
100
- More details about how to setup the debugger can be found in Microsoft's website:
132
+ More details about how to set up the debugger can be found in Microsoft's website:
101
133
102
134
- General information about debugging in VS Code: < https://code.visualstudio.com/docs/editor/debugging >
103
135
- C/C++ extension debugger information: < https://code.visualstudio.com/docs/cpp/cpp-debug >
@@ -141,22 +173,22 @@ installed with `pip` automatically through the extension.
141
173
142
174
| findent | fprettify |
143
175
| :-------------------------------: | :---------------------------------: |
144
- | ![ alt] ( ./images /findent-demo.gif ) | ![ alt] ( ./images /fprettify-demo.gif ) |
176
+ | ![ alt] ( ./assets /findent-demo.gif ) | ![ alt] ( ./assets /fprettify-demo.gif ) |
145
177
146
178
The formatter is controlled by the user option
147
179
148
180
``` jsonc
149
181
{
150
- " fortran.formatting.formatter" : " findent" // "fprettify" or "Disabled"
182
+ " fortran.formatting.formatter" : " findent" | " fprettify" | " Disabled"
151
183
}
152
184
```
153
185
154
186
Additional arguments to the formatter can be input using
155
187
156
188
``` json
157
189
{
158
- "fortran.formatting.findentArgs" : [" -Cn" , " -Rr" ],
159
- "fortran.formatting.fprettifyArgs" : [" --whitespace-comma" , " --enable-decl" ]
190
+ "fortran.formatting.findentArgs" : [" -Cn" , " -Rr" ],
191
+ "fortran.formatting.fprettifyArgs" : [" --whitespace-comma" , " --enable-decl" ]
160
192
}
161
193
```
162
194
@@ -168,9 +200,46 @@ If the formatter is not present in the `PATH` its location can be input with
168
200
}
169
201
```
170
202
171
- ### NOTE: About ` findent `
203
+ | :memo : Note |
204
+ | ---------------------------------------------------------------------- |
205
+ | ` findent ` can also be used to generate dependency files for a project. |
206
+
207
+ ## Snippets
208
+
209
+ Snippets are included by both ` fortls ` Language Server and the Modern Fortran VS Code extension.
210
+ Some available snippets can be seen below. Users can define their own snippets
211
+ by following these VS Code [ instructions] ( https://code.visualstudio.com/docs/editor/userdefinedsnippets ) .
212
+
213
+ If you think a snippet should be shipped by with the extension feel free to
214
+ submit a [ feature request] ( https://github.com/fortran-lang/vscode-fortran-support/issues/new?assignees=&labels=feature-request&template=feature_request.md&title= )
215
+
216
+ ### Program skeleton
217
+
218
+ ![ program snippet] ( https://media.giphy.com/media/OYdq9BKYMOOdy/giphy.gif )
219
+
220
+ #### Module skeleton
221
+
222
+ ![ module snippet] ( https://media.giphy.com/media/3ohzdUNRuio5FfyF1u/giphy.gif )
223
+
224
+ ## Advanced options
225
+
226
+ To show the symbols in the file outline enable ` provide.symbols ` . Symbols can be
227
+ served by the fortls, the built-in, both or none. By default
228
+ ` fortls ` is used.
229
+
230
+ ``` jsonc
231
+ {
232
+ " fortran.provide.symbols" : " fortls" | " Built-in" | " Both" | " Disable"
233
+ }
234
+ ```
235
+
236
+ You can also configure the case for fortran intrinsics auto-complete by using
172
237
173
- ` findent ` can also be used to generate dependency files for a project.
238
+ ``` jsonc
239
+ {
240
+ " fortran.preferredCase" : " lowercase" | " uppercase"
241
+ }
242
+ ```
174
243
175
244
## All options
176
245
@@ -204,8 +273,6 @@ A summary of all the options
204
273
205
274
## Requirements
206
275
207
- For the linter to work you need to have ` gfortran ` on your path, or wherever you configure it to be.
208
-
209
276
For debugging you need to have one of the following debuggers installed:
210
277
211
278
- ** Linux** : GDB
0 commit comments