Hi @seme4ka008, welcome.
Please follow these steps mentioned on the Modern Fortran- VSCode pageModern Fortran- Visual Studio
Here are possible steps, which you should follow (copying text from the page mentioned above):
- Allow for
fortls
to be automatically installed withpip
orAnaconda
and if the location wherefortls
is installed is not in yourPATH
point VS Code to thefortls
location by setting
{
"fortran.fortls.path": "/custom/path/to/fortls"
}
- Linting: may be you can safely ignore if you are using gfortran.
By default, the linter used is gfortran
, Intel’s ifort
and Intel’s LLVM based compiler ifx
are also supported. One can use a different linter compiler via the option
{
"fortran.linter.compiler": "ifx/gfortran"
}
- Debugging: The extension uses the debugger from Microsoft’s C/C++ extension for Visual Studio Code. This allows this extension to use the full functionality of the C/C++ extension for debugging applications.
Therefore C/C++ extensions are necessary.
- Formatting:
Two formatters are supported findent
and fprettify
. Both of them can be installed with pip
automatically through the extension.
The formatter is controlled by the user option
{
"fortran.formatting.formatter": "findent" | "fprettify" | "Disabled"
}
In nutshell, you need to install ifortls and fprettify/findent though conda or pip.
For fortls:
With
pip
pip uninstall fortran-language-server
pip install fortls --upgradeor with Anaconda
conda uninstall fortran-language-server
conda install -c conda-forge fortls
for fprettify:
pip install fprettify
conda install -c programfan fprettify
Hope this helps. Good luck!!