-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Variable definition from C++ header #115
Comments
Currently, As for the preprocessor definitions, you can define these globally as you would in compile commands. So if they are the same for the entire project that should be a decent work around in the interim. For example to define the case you gave above you would add the following to your
|
Perfect. Thank you!
I have tested that, if I were to rename all the files in our project from .f90 to .F90, this would be a perfect workaround for now. I would, however, rather not do the renaming. Is there any specific reason for the restriction to all caps file endings? Or is there any way for me to include .f90 files in the preprocessing? |
Ah, I see. Yes, that was chosen because by default this is how most compilers handle preprocessing for Fortran files (ex. gcc). I will also add an option to allow you to specify any suffix for preprocessing. |
- Limited to preprocessing only (no Fortran objects) - Update README formatting
I just pushed some changes up to the next version branch (see above) to work towards adding this functionality. The |
Thanks a lot for the fast changes! I checked the commit 7a8ccd9 and the problem due to non-caps file names is solved. I can now jump to definitions or get information on hovering for variable types which I added via "pp_defs" in the .fortls file. I didn't have the time yet to take a look at the changes in 7697fcd though. |
@JayPBe: Just an additional note, which might or might not helpful. We have a very similar naming scheme, and I simply maintain a oneline patch, so that fortls thinks that real4us is a type. This has the advantage that the editor really shows real4us and not real(8). (We have several real4xyz macros, and I want to see the type name, not the kind number.) Here is an example oneline patch (copy from git diff output):
|
Thank you for this great suggestion. Works like a charm and I think I even prefer this over the previous workaround! |
Hello,
I am currently using the Geany editor to work on a large fortran project and wanted to try out the fortran language server in conjunction with VS Code as an alternative.
I have everything set up now, but I am having problems due to our specific project structure. Most subroutines have statements of the type
#include declarations.h
or
#include common_constants.h
i.e. C++ header files with type declarations or global variables are included.
Firstly, VS Code is unable to jump to these .h files via "go to definition" or "strg+left click" from these
#include
statements within a .f90 file. It further shows a "No such file or directory" message under the problems tabs in VS Code. (Although the .h files are all within the workspace folder).I imagine this is because the language server is not parsing non-fortran files? Is there any way to still obtain the desired behavior?
Secondly, inside these header files data types are defined. They follow the pattern
_<FortranType>4us_
, i.e. we could have a line#define _real4us_ real*8
in the .h header file and a definition
_real4us_ :: x,y
in a f90 fortran source file. In this case jumping to the definition or getting information from hovering over x and y will not be possible. I imagine retrieving the definitions from the ".h" files would be very complicated. Alternatively, it would help me a great deal if I could manually add all necessary
_<FortranType>4us_
types and enable the definition feature for them.I hope that the above issues are actually related to the language server and not VS Code or the modern fortran extension. If not, please refer me to the correct location to post my questions.
Thanks in advance.
The text was updated successfully, but these errors were encountered: