fortran-lang / fortls

fortls - Fortran Language Server
https://fortls.fortran-lang.org/
MIT License
257 stars 41 forks source link

Leave blank spaces in front of C preprocessing directives #297

Closed fredcouderc closed 7 months ago

fredcouderc commented 1 year ago

For the sake of code readability, I like to be able to leave blank spaces front of C preprocessing directives,

PROGRAM test

   implicit none

   #if defined USE_DOUBLE
   real(8) :: r
   #else
   real(4) :: r
   #endif

END PROGRAM

which I then process with sed directives before compilation in my makefile.

It is possible to add this possibility in regex formulas and have no error of kind: Variable "r" declared twice in scope ?

Thanks very much

gnikit commented 1 year ago

Off the top of my head it should be possible. The main complication would be if the preprocessor heuristics interfered with the main fortls functionality (which I think is the case). Currently and intentionally, these 2 are quite separate.

In general, the expectations for fortls should be that it is able to provide LSP support for valid (or soon to be valid) Fortran code. I am afraid that any syntax outside of that like convenience modifications and vendor specific extensions fall at the bottom of the priority list.

emanspeaks commented 11 months ago

I am working on a PR for a similar issue (spaces between the hash and the directive), so I'll test out adding spaces in front as well and include that in my submission