runtime(fortran): update syntax and ftplugins

closes: #13629

Signed-off-by: Ajit-Thakkar <142174202+Ajit-Thakkar@users.noreply.github.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Ajit-Thakkar
2023-12-05 23:07:27 +01:00
committed by Christian Brabandt
parent 4e043b1fc7
commit 6863084d3b
6 changed files with 213 additions and 277 deletions
+42 -64
View File
@@ -1,4 +1,4 @@
*syntax.txt* For Vim version 9.0. Last change: 2023 Apr 24
*syntax.txt* For Vim version 9.0. Last change: 2023 Dec 05
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -1591,7 +1591,15 @@ FORTRAN *fortran.vim* *ft-fortran-syntax*
Default highlighting and dialect ~
Highlighting appropriate for Fortran 2008 is used by default. This choice
should be appropriate for most users most of the time because Fortran 2008 is
almost a superset of previous versions (Fortran 2003, 95, 90, and 77).
almost a superset of previous versions (Fortran 2003, 95, 90, and 77). A
small number of features new to Fortran 2018 and Fortran 2023 are supported
and the complete transition to Fortran 2023 will be completed in the future.
A few legacy constructs deleted or declared obsolescent in recent Fortran
standards are highlighted as todo items.
The syntax script no longer supports Fortran dialects. The variable
fortran_dialect is now silently ignored. Since computers are much faster now,
the variable fortran_more_precise is no longer needed and is silently ignored.
Fortran source code form ~
Fortran code can be in either fixed or free source form. Note that the
@@ -1618,14 +1626,36 @@ neither of these variables have been set, the syntax script attempts to
determine which source form has been used by examining the file extension
using conventions common to the ifort, gfortran, Cray, NAG, and PathScale
compilers (.f, .for, .f77 for fixed-source, .f90, .f95, .f03, .f08 for
free-source). If none of this works, then the script examines the first five
columns of the first 500 lines of your file. If no signs of free source form
are detected, then the file is assumed to be in fixed source form. The
algorithm should work in the vast majority of cases. In some cases, such as a
file that begins with 500 or more full-line comments, the script may
incorrectly decide that the fortran code is in fixed form. If that happens,
just add a non-comment statement beginning anywhere in the first five columns
of the first twenty-five lines, save (:w) and then reload (:e!) the file.
free-source). No default is used for the .fpp and .ftn file extensions because
different compilers treat them differently. If none of this works, then the
script examines the first five columns of the first 500 lines of your file. If
no signs of free source form are detected, then the file is assumed to be in
fixed source form. The algorithm should work in the vast majority of cases.
In some cases, such as a file that begins with 500 or more full-line comments,
the script may incorrectly decide that the code is in fixed form. If that
happens, just add a non-comment statement beginning anywhere in the first five
columns of the first twenty-five lines, save (:w), and then reload (:e!) the
file.
Vendor extensions ~
Fixed-form Fortran requires a maximum line length of 72 characters but the
script allows a maximum line length of 80 characters as do all compilers
created in the last three decades. An even longer line length of 132
characters is allowed if you set the variable fortran_extended_line_length
with a command such as >
:let fortran_line_length=1
placed prior to the :syntax on command.
If you want additional highlighting of the CUDA Fortran extensions, you should
set the variable fortran_CUDA with a command such as >
:let fortran_CUDA=1
placed prior to the :syntax on command.
To activate recognition of some common, non-standard, vendor-supplied
intrinsics, you should set the variable fortran_vendor_intrinsics with a
command such as >
:let fortran_vendor_intrinsics=1
placed prior to the :syntax on command.
Tabs in fortran files ~
Tabs are not recognized by the Fortran standards. Tabs are not a good idea in
@@ -1647,8 +1677,8 @@ subprograms, block data subprograms, interface blocks, and modules. If you
also set the variable fortran_fold_conditionals with a command such as >
:let fortran_fold_conditionals=1
then fold regions will also be defined for do loops, if blocks, and select
case constructs. If you also set the variable
fortran_fold_multilinecomments with a command such as >
case constructs. If you also set the variable fortran_fold_multilinecomments
with a command such as >
:let fortran_fold_multilinecomments=1
then fold regions will also be defined for three or more consecutive comment
lines. Note that defining fold regions can be slow for large files.
@@ -1659,58 +1689,6 @@ you set foldmethod=syntax. Comments or blank lines placed between two program
units are not folded because they are seen as not belonging to any program
unit.
More precise fortran syntax ~
If you set the variable fortran_more_precise with a command such as >
:let fortran_more_precise=1
then the syntax coloring will be more precise but slower. In particular,
statement labels used in do, goto and arithmetic if statements will be
recognized, as will construct names at the end of a do, if, select or forall
construct.
Non-default fortran dialects ~
The syntax script supports two Fortran dialects: f08 and F. You will probably
find the default highlighting (f08) satisfactory. A few legacy constructs
deleted or declared obsolescent in the 2008 standard are highlighted as todo
items.
If you use F, the advantage of setting the dialect appropriately is that
other legacy features excluded from F will be highlighted as todo items and
that free source form will be assumed.
The dialect can be selected in various ways. If all your fortran files use
the same dialect, set the global variable fortran_dialect in your .vimrc prior
to your syntax on statement. The case-sensitive, permissible values of
fortran_dialect are "f08" or "F". Invalid values of fortran_dialect are
ignored.
If the dialect depends upon the file extension, then it is most convenient to
set a buffer-local variable in a ftplugin file. For more information on
ftplugin files, see |ftplugin|. For example, if all your fortran files with
an .f90 extension are written in the F subset, your ftplugin file should
contain the code >
let s:extfname = expand("%:e")
if s:extfname ==? "f90"
let b:fortran_dialect="F"
else
unlet! b:fortran_dialect
endif
Note that this will work only if the "filetype plugin indent on" command
precedes the "syntax on" command in your .vimrc file.
Finer control is necessary if the file extension does not uniquely identify
the dialect. You can override the default dialect, on a file-by-file basis,
by including a comment with the directive "fortran_dialect=xx" (where xx=F or
f08) in one of the first three lines in your file. For example, your older .f
files may be legacy code but your newer ones may be F codes, and you would
identify the latter by including in the first three lines of those files a
Fortran comment of the form >
! fortran_dialect=F
For previous versions of the syntax, you may have set fortran_dialect to the
now-obsolete values "f77", "f90", "f95", or "elf". Such settings will be
silently handled as "f08". Users of "elf" may wish to experiment with "F"
instead.
The syntax/fortran.vim script contains embedded comments that tell you how to
comment and/or uncomment some lines to (a) activate recognition of some
non-standard, vendor-supplied intrinsics and (b) to prevent features deleted