fortran-lang / vscode-fortran-support

Fortran language support for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=fortran-lang.linter-gfortran
MIT License
221 stars 30 forks source link

feat: Improved Module Support for Linting Diagnostics #990

Open dnwillia-work opened 1 year ago

dnwillia-work commented 1 year ago

Is there an existing request for this?

Feature Request

In issue #175 I requested the ability to control where the Fortran modules are placed and this has since been added, which is great. However, you might note this comment.

This is still the behaviour today. In order to get rid of the red squiggles on the use module_name statements you have to go and load the code that contains the module module_name so that the .mod file is generated into the output directory. It's working but you need to click on them one by one.

It would be much better if the .mod files are generated on the fly when you load a particular source file.

This is an issue on both Windows, when configured with Intel Fortran, and Linux/MacOS when configured with gfortran.

gnikit commented 1 year ago

This is essentially a build system request, which would be very useful. A basic attempt to solve this has been added to the pre-release which I would strongly advise you to try. The option is under the linter settings fortran.linter.initialize. A better solution would involve using `

All three are not that simple to implement, especially since vscode does not have an elegant way of opening and closing files.

The only realistic solution, if working on a very large project is to build the project a-priori and then point the linter to the location of the .mod files.

gnikit commented 1 year ago

I think this won't make it in the next release, which has been finished but remained in a pre-release stage for some time now, but I would like to include it in the next year's roadmap.

phil-blain commented 2 weeks ago

I tried fortran.linter.initialize but it tries to lint all workspace files in the order it receives them from getFiles, so in a large project all these linter invocation mostly fail because Fortran modules must be compiled in a specific order.

I think it would make more sense to allow fortran.linter.initialize to point to a specific VSCode task. This way the task could precompile the project such that all modules are created in the correct order. This was suggested in https://github.com/fortran-lang/vscode-fortran-support/issues/175#issuecomment-666007292.