From 7121241e5cecbd741795aec37a3cb1203c8e9f34 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Sat, 23 Dec 2023 11:38:18 +0100 Subject: [PATCH] vim-patch:ea9964a36f94 Runtime(fortran): updates to indent, syntax and ftplugin (vim/vim#13752) * runtime update fortran.vim Add folding for newer features of Fortran * Runtime Update fortran.vim Add indent support for newer features of Fortran * Runtime Update fortran.vim Add newer features of Fortran to matchit patterns https://github.com/vim/vim/commit/ea9964a36f948c1266d43dd8b3890c6f3bdd243d Co-authored-by: Ajit-Thakkar <142174202+Ajit-Thakkar@users.noreply.github.com> --- runtime/ftplugin/fortran.vim | 11 ++++++++--- runtime/indent/fortran.vim | 21 +++++++++++---------- runtime/syntax/fortran.vim | 30 +++++++++++++++++++----------- 3 files changed, 38 insertions(+), 24 deletions(-) diff --git a/runtime/ftplugin/fortran.vim b/runtime/ftplugin/fortran.vim index a057db9a4b..d714a4ac4f 100644 --- a/runtime/ftplugin/fortran.vim +++ b/runtime/ftplugin/fortran.vim @@ -1,6 +1,6 @@ " Vim settings file -" Language: Fortran 2008 (and older: Fortran 2003, 95, 90, 77, 66) -" Version: (v54) 2023 December 5 +" Language: Fortran 2023 (and Fortran 2018, 2008, 2003, 95, 90, 77, 66) +" Version: (v55) 2023 December 22 " Maintainers: Ajit J. Thakkar ; " Joshua Hollett " Usage: For instructions, do :help fortran-plugin from Vim @@ -110,7 +110,9 @@ if !exists("b:match_words") let b:match_ignorecase = 1 let b:match_words = \ '(:),' . - \ '\:' . s:notselect. '\:\,' . + \ s:notend .'\:' . s:notselect. '\:\,' . + \ s:notend .'\:' . s:notselect. '\:\,' . + \ s:notend .'\:' . s:notselect. '\:\,' . \ s:notelse . '\:' . \ s:nothash . '\:' . s:nothash . '\,'. \ 'do\s\+\(\d\+\):\%(^\s*\)\@<=\1\s,'. @@ -119,6 +121,9 @@ if !exists("b:match_words") \ s:notend . '\,'. \ s:notend . '\:\,'. \ s:notend . '\:\,'. + \ s:notend . '\:\,'. + \ s:notend . '\:\,'. + \ s:notend . '\:\,'. \ s:notend . '\:\,'. \ s:notend . '\:\,'. \ s:notend . '\:\,'. diff --git a/runtime/indent/fortran.vim b/runtime/indent/fortran.vim index 7130658f59..392b2d29d5 100644 --- a/runtime/indent/fortran.vim +++ b/runtime/indent/fortran.vim @@ -1,6 +1,6 @@ " Vim indent file -" Language: Fortran 2008 (and Fortran 2003, 95, 90, and 77) -" Version: (v49) 2023 December 1 +" Language: Fortran 2023 (and Fortran 2018, 2008, 2003, 95, 90, 77, 66) +" Version: (v50) 2023 December 22 " Maintainers: Ajit J. Thakkar ; " Joshua Hollett " Usage: For instructions, do :help fortran-indent from Vim @@ -22,8 +22,8 @@ let b:undo_indent = "setl inde< indk<" setlocal indentkeys+==~end,=~case,=~if,=~else,=~do,=~where,=~elsewhere,=~select setlocal indentkeys+==~endif,=~enddo,=~endwhere,=~endselect,=~elseif -setlocal indentkeys+==~type,=~interface,=~forall,=~associate,=~block,=~enum -setlocal indentkeys+==~endforall,=~endassociate,=~endblock,=~endenum +setlocal indentkeys+==~interface,=~forall,=~associate,=~block,=~enum,=~critical +setlocal indentkeys+==~endforall,=~endassociate,=~endblock,=~endenum,=~endcritical if exists("b:fortran_indent_more") || exists("g:fortran_indent_more") setlocal indentkeys+==~function,=~subroutine,=~module,=~contains,=~program setlocal indentkeys+==~endfunction,=~endsubroutine,=~endmodule @@ -49,7 +49,7 @@ if !exists("b:fortran_fixed_source") " Fixed-form file extension defaults let b:fortran_fixed_source = 1 else - " Modern fortran still allows both fixed and free source form + " Modern fortran compilers still allow both fixed and free source form " Assume fixed source form unless signs of free source form " are detected in the first five columns of the first s:lmax lines. " Detection becomes more accurate and time-consuming if more lines @@ -109,8 +109,9 @@ function FortranGetIndent(lnum) "Add a shiftwidth to statements following if, else, else if, case, class, "where, else where, forall, type, interface and associate statements - if prevstat =~? '^\s*\(case\|class\|else\|else\s*if\|else\s*where\)\>' - \ ||prevstat=~? '^\s*\(type\|interface\|associate\|enum\)\>' + if prevstat =~? '^\s*\(case\|class\s\+is\|else\|else\s*if\|else\s*where\)\>' + \ ||prevstat=~? '^\s*\(type\|rank\|interface\|associate\|enum\|critical\)\>' + \ ||prevstat=~? '^\s*change\s\+team\>' \ ||prevstat=~?'^\s*\(\d\+\s\)\=\s*\(\a\w*\s*:\)\=\s*\(forall\|where\|block\)\>' \ ||prevstat=~? '^\s*\(\d\+\s\)\=\s*\(\a\w*\s*:\)\=\s*if\>' let ind = ind + shiftwidth() @@ -145,10 +146,10 @@ function FortranGetIndent(lnum) "Subtract a shiftwidth from else, else if, elsewhere, case, class, end if, " end where, end select, end forall, end interface, end associate, - " end enum, end type, end block and end type statements + " end enum, end type, end block, end team and end type statements if getline(v:lnum) =~? '^\s*\(\d\+\s\)\=\s*' - \. '\(else\|else\s*if\|else\s*where\|case\|class\|' - \. 'end\s*\(if\|where\|select\|interface\|' + \. '\(else\|else\s*if\|else\s*where\|case\|class\|rank\|type\s\+is\|' + \. 'end\s*\(if\|where\|select\|interface\|critical\|team\|' \. 'type\|forall\|associate\|enum\|block\)\)\>' let ind = ind - shiftwidth() " Fix indent for case statement immediately after select diff --git a/runtime/syntax/fortran.vim b/runtime/syntax/fortran.vim index 7ed4f8a268..b7fae54d99 100644 --- a/runtime/syntax/fortran.vim +++ b/runtime/syntax/fortran.vim @@ -1,6 +1,6 @@ " Vim syntax file " Language: Fortran 2023 (and Fortran 2018, 2008, 2003, 95, 90, and 77) -" Version: (v107) 2023 December 17 +" Version: (v108) 2023 December 22 " Maintainers: Ajit J. Thakkar ; " Joshua Hollett " Usage: For instructions, do :help fortran-syntax from Vim @@ -75,6 +75,8 @@ syn match fortranConstructName "\(\" +syn match fortranConstructName "\(\" +syn match fortranConstructName "\(\" syn match fortranUnitName "\(\(end\s*\)\?\(subroutine\|function\|module\|program\|submodule\)\s\+\)\@12<=\a\w\+" syn match fortranUnitHeader "\\ze\s*(' +syn keyword fortranIntrinsic spread system_clock transpose trim ubound unpack verify syn keyword fortranIntrinsic atomic_define atomic_ref execute_command_line leadz trailz storage_size merge_bits syn keyword fortranIntrinsic bge bgt ble blt dshiftl dshiftr findloc iall iany iparity image_index lcobound ucobound maskl maskr num_images parity popcnt poppar shifta shiftl shiftr this_image syn keyword fortranIntrinsic null cpu_time failed_images stopped_images image_status co_broadcast co_max co_min co_sum co_reduce @@ -99,7 +104,6 @@ syn keyword fortranIntrinsic iso_c_binding c_loc c_funloc c_sizeof c_associat syn keyword fortranIntrinsic out_of_range reduce random_init coshape syn keyword fortranIntrinsic acosd asind atand atan2d cosd sind tand acospi asinpi atanpi atan2pi cospi sinpi tanpi syn keyword fortranIntrinsic compiler_options compiler_version get_team team_number -"syn match fortranIntrinsic '\<\(count\|dot_product\|epsilon\|exponent\|fraction\|matmul\|maxval\|minval\|modulo\|nearest\|pack\|precision\|product\|radix\|random_number\|random_seed\|range\|repeat\|reshape\|rrspacing\|scale\|scan\|set_exponent\|shape\|size\|sum\|tiny\|transpose\)\>\ze\s*(' syn match fortranIntrinsic "\