Hello,
I am running VS Code on Windows with the Modern Fortran extension. I have installed fortls (not fortran-language-server, but fortls). I also have the mingw toolchain with gfortran (with the correct path added to the PATH environment variable).
I have a fortran project with source code across several files (most in the same directory, but for now we can consider them all in the same directory).
Almost everything seems to work correctly “across files”, eg :
- Autocompletion is configured to use fortls (which is the default anyway), and will correctly suggest functions that are defined/coded in another file of the project
- Hovering is configured to use fortls as well (again, the default), and hovering over a function call will correctly display an overview of how it should be called, even if said function is in another file
- Right-click->Go to Definition will open a tab and point me to the relevant code section, even if that is in another file
Static syntax analysis seems to work fine for anything that can be checked inside a given file. For example, if I have a function f coded in file A.f, and somewhere else in A.f try to call f with the wrong number of arguments, the editor adequately signals an error. Great !
But if the same function f from A.f is called from another file B.f in the same directory, then the same errors won’t be caught and no error is signaled by the editor. They will only be caught and signaled for calls made inside the same physical file.
I am not sure what to do to remedy this. I have added the following to the VSCode settings.json file, but to no effect
"fortran.linter.includePaths": [
"${workspaceFolder}/**"
],
"fortran.linter.modOutput": "${workspaceFolder}/.vscode/linter",
"fortran.fortls.suffixes": [
"f"
],
"fortran.fortls.directories": [
"./**"
],
"fortran.fortls.preprocessor.suffixes": [
".f"
],
Would anyone know how to fix this ? Thanks for your help !
edit : if that is of any help, here is the output pane of VS Code after launching VS Code (everything seems fine I guess ?)
["INFO" - 5:57:48 PM] Extension Name: Modern Fortran
["INFO" - 5:57:48 PM] Extension Version: 3.2.0
["INFO" - 5:57:48 PM] Linter set to: gfortran
["INFO" - 5:57:48 PM] Formatter set to: findent
["INFO" - 5:57:48 PM] Autocomplete set to: fortls
["INFO" - 5:57:48 PM] Hover set to: fortls
["INFO" - 5:57:48 PM] Symbols set to: fortls
["INFO" - 5:57:48 PM] using linter: gfortran located in: D:\Logiciels\GCC\bin\gfortran.EXE
["INFO" - 5:57:48 PM] Linter.arguments:
-Wall
-ffree-line-length-none
-ffixed-line-length-none
["INFO" - 5:57:48 PM] Linter.moduleOutput: -J d:\Work\ZHCW\sources/.vscode/linter
["INFO" - 5:57:48 PM] Linter.include:
${workspaceFolder}/**
["INFO" - 5:57:48 PM] Fortran Language Server
["INFO" - 5:57:49 PM] Initialising Language Server for workspace: d:\Work\ZHCW\sources\zhcw.f with command-line options: --enable_code_actions, --autocomplete_no_prefix, --hover_signature, --use_signature_help, --lowercase_intrinsics, --nthreads=4, --incremental_sync, --disable_autoupdate, --incl_suffixes, f, --source_dirs, ./**, --pp_suffixes, .f
[INFO - 17:57:50] fortls - Fortran Language Server 2.13.0 Initialized