vscode-fortran-support
vscode-fortran-support copied to clipboard
Customizable line width past 72 characters in Fixed Form
Description
In certain cases, some are shown below in the MWE, the syntax highlighting marks the 73rd character as a comment.
Request
Make the number of characters in a line that are coloured as input (and not comments) a user input variable.
MWE
C F77 MWE syntax highlighting breaking at line
PROGRAM TEST
integer :: i = 10
! Character 73 begins here -------------------------------------->
print*, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i,
print*, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i,i, i,
print*, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i,i,i, i
print*, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19
print*, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,18, 19
print*, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, (1), 18, 19
print*, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 1, 18, 19
END PROGRAM TEST
Highlighting
Original Post
Hi,
I use fixed-form Fortran with 132 columns. Visual Studio already has a setting for increasing the line width, but none of the VScode Fortran extensions have it. Is it possible to add the line width as a variable that can be changed in the settings? Thanks!
Hey, thanks for creating an issue. Can you elaborate more on this? Like what kind of behaviour are you expecting to see. And how that is not possible to be accomplished by VS Code itself?
Hi, thanks for the response!
In gfortran, there is the option -ffixed-line-length-n
which controls the column after which characters are ignored and treated as comments.
from here:
Popular values for n include 72 (the standard and the default), 80 (card image), and 132 (corresponding to “extended-source” options in some popular compilers)
In its current state, the syntax highlighting for fixed-form Fortran in the extension only supports a line length of 72 characters. Anything after column 72 appears as comments (green) in the source code, which also affects the appearance of the following lines (when a closing parenthesis is in this green region for example)
The software I work with uses a line length of 132. So a desired behavior in such case would be to include a option (fortran.fixedLineLength
for example) which allows the user to control the value of n
of fixed form files both for the compiler and the syntax highlighting.
I know where this option is in our extension, but don't know how to make it variable since it's hardcoded inside a json file fortran_fixed-form.tmLanguage.json.
That line-end-comment
scope controls exactly what you want.
Thats a tricky problem. Maybe having instead of only one option we can add those other common ones like you mentioned?
Thats a tricky problem. Maybe having instead of only one option we can add those other common ones like you mentioned?
That'd be a great option as well. It is how Intel Fortran Compiler is configured in Visual Studio Pro, so it must be safe to assume only these 3 options (see screenshot)
@krvajal Can you guide me in this? ... Everywhere i look the syntax of fortran_fixed-form
is set by .json files...
I thought about creating different .json files having only line-end-comment
scope, somethig like:
- line_end_72.json
- line_end_80.json
- line_end_132.json
and including them in fortran_fixed-form.tmLanguage.json
as set by a configuration variable.
To make this If
and access the extension configuration, i believe i need a .ts file
And i got no idea how or where to do it ! =]
It appears that we are not the only ones with a need to dynamically generate grammars. This issue is being tracked here https://github.com/microsoft/vscode/issues/68647 . Some workarounds have been offered
@tymric please let me know if you found any solution to this problem.