Skip to content

Commit d96f25b

Browse files
authored
runtime(fortran): update syntax and documentation (#13784)
* Update Fortran section of indent.txt * Small addition to fortran syntax Signed-off-by: Ajit-Thakkar <[email protected]> Signed-off-by: Eisuke Kawashima <[email protected]> Signed-off-by: Christian Brabandt <[email protected]> * Update Fortran section of syntax.txt * Runtime (Fortran) Fix regression * Combine two expressions
1 parent 7e4f62a commit d96f25b

3 files changed

Lines changed: 28 additions & 23 deletions

File tree

runtime/doc/indent.txt

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*indent.txt* For Vim version 9.0. Last change: 2023 Dec 23
1+
*indent.txt* For Vim version 9.0. Last change: 2023 Dec 27
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -712,15 +712,16 @@ clojure-mode.el:
712712

713713
FORTRAN *ft-fortran-indent*
714714

715-
Block if, select case, where, and forall constructs are indented. So are
716-
type, interface, associate, block, and enum constructs. The indenting of
717-
subroutines, functions, modules, and program blocks is optional. Comments,
718-
labeled statements, and continuation lines are indented if the Fortran is in
719-
free source form, whereas they are not indented if the Fortran is in fixed
720-
source form because of the left margin requirements. Hence manual indent
721-
corrections will be necessary for labeled statements and continuation lines
722-
when fixed source form is being used. For further discussion of the method
723-
used for the detection of source format see |ft-fortran-syntax|.
715+
Block if, select case, select type, select rank, where, forall, type,
716+
interface, associate, block, enum, critical, and change team constructs are
717+
indented. The indenting of subroutines, functions, modules, and program blocks
718+
is optional. Comments, labeled statements, and continuation lines are indented
719+
if the Fortran is in free source form, whereas they are not indented if the
720+
Fortran is in fixed source form because of the left margin requirements. Hence
721+
manual indent corrections will be necessary for labeled statements and
722+
continuation lines when fixed source form is being used. For further
723+
discussion of the method used for the detection of source format see
724+
|ft-fortran-syntax|.
724725

725726
Do loops ~
726727
All do loops are left unindented by default. Do loops can be unstructured in

runtime/doc/syntax.txt

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*syntax.txt* For Vim version 9.0. Last change: 2023 Dec 23
1+
*syntax.txt* For Vim version 9.0. Last change: 2023 Dec 27
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -1674,21 +1674,22 @@ fortran_fold with a command such as >
16741674
:let fortran_fold=1
16751675
to instruct the syntax script to define fold regions for program units, that
16761676
is main programs starting with a program statement, subroutines, function
1677-
subprograms, block data subprograms, interface blocks, and modules. If you
1678-
also set the variable fortran_fold_conditionals with a command such as >
1677+
subprograms, modules, submodules, and block data units. Block, interface,
1678+
associate, critical, type definition, and change team constructs will also be
1679+
folded. If you also set the variable fortran_fold_conditionals with a command
1680+
such as >
16791681
:let fortran_fold_conditionals=1
1680-
then fold regions will also be defined for do loops, if blocks, and select
1681-
case constructs. If you also set the variable fortran_fold_multilinecomments
1682-
with a command such as >
1682+
then fold regions will also be defined for do loops, if blocks, select case,
1683+
select type, and select rank constructs. If you also set the variable
1684+
fortran_fold_multilinecomments with a command such as >
16831685
:let fortran_fold_multilinecomments=1
16841686
then fold regions will also be defined for three or more consecutive comment
16851687
lines. Note that defining fold regions can be slow for large files.
16861688

16871689
If fortran_fold, and possibly fortran_fold_conditionals and/or
1688-
fortran_fold_multilinecomments, have been set, then vim will fold your file if
1689-
you set foldmethod=syntax. Comments or blank lines placed between two program
1690-
units are not folded because they are seen as not belonging to any program
1691-
unit.
1690+
fortran_fold_multilinecomments, have been set, then vim will fold your file.
1691+
Comments or blank lines placed between two program units are not folded
1692+
because they are seen as not belonging to any program unit.
16921693

16931694
The syntax/fortran.vim script contains embedded comments that tell you how to
16941695
comment and/or uncomment some lines to (a) activate recognition of some

runtime/syntax/fortran.vim

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
" Vim syntax file
22
" Language: Fortran 2023 (and Fortran 2018, 2008, 2003, 95, 90, and 77)
3-
" Version: (v108) 2023 December 22
3+
" Version: (v109) 2023 December 29
44
" Maintainers: Ajit J. Thakkar <[email protected]>; <https://ajit.ext.unb.ca/>
55
" Joshua Hollett <[email protected]>
66
" Usage: For instructions, do :help fortran-syntax from Vim
@@ -133,8 +133,8 @@ syn keyword fortranAttribute abstract external private public protected inten
133133
syn keyword fortranAttribute pointer target allocatable dimension codimension sequence parameter save
134134

135135
syn keyword fortranUnitHeader result operator assignment
136-
syn match fortranUnitHeader "\(end\s*\)\?\(subroutine\|function\|module\|program\|submodule\)\>"
137-
syn match fortranBlock "\(end\s*\)\?\(block\|critical\|associate\)\>"
136+
syn match fortranUnitHeader "\<\(end\s*\)\?\(subroutine\|function\|module\|program\|submodule\)\>"
137+
syn match fortranBlock "\<\(end\s*\)\?\(block\|critical\|associate\)\>"
138138
syn match fortranCalled "\(call\s\+\)\@7<=\a\w*"
139139
syn match fortranRepeat "\<do\>"
140140
syn keyword fortranRepeat concurrent
@@ -349,6 +349,9 @@ endif
349349

350350
if exists("fortran_fold")
351351

352+
if has("folding")
353+
setlocal foldmethod=syntax
354+
endif
352355
if (b:fortran_fixed_source == 1)
353356
syn region fortranProgram transparent fold keepend start="^\s*program\s\+\z(\a\w*\)" skip="^\([!c*]\|\s*#\).*$" excludenl end="\<end\s*\(program\(\s\+\z1\>\)\=\|$\)" contains=ALLBUT,fortranModule
354357
syn region fortranModule transparent fold keepend start="^\s*submodule\s\+(\a\w*\s*\(:\a\w*\s*\)*)\s*\z\(\a\w*\)" skip="^\([!c*]\|\s*#\).*$" excludenl end="\<end\s*\(submodule\(\s\+\z1\>\)\=\|$\)" contains=ALLBUT,fortranProgram,fortranModule

0 commit comments

Comments
 (0)