runtime(vim): update indentation plugin for Vim script

Commit: 
https://github.com/vim/vim/commit/6d2efd492010cc12e9eeec3ad2bb2645106e0087
Author: Jim Zhou <csd_...@163.com>
Date:   Thu Dec 26 10:30:37 2024 +0100

    runtime(vim): update indentation plugin for Vim script
    
    Make the indent script aware of enums and ensure those will be correctly
    indented.
    
    fixes: #16289
    closes: #16293
    
    Co-authored-by: Aliaksei Budavei <0x000...@gmail.com>
    Signed-off-by: Jim Zhou <csd_...@163.com>
    Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/runtime/autoload/dist/vimindent.vim 
b/runtime/autoload/dist/vimindent.vim
index 727e98352..0681496ae 100644
--- a/runtime/autoload/dist/vimindent.vim
+++ b/runtime/autoload/dist/vimindent.vim
@@ -2,11 +2,12 @@ vim9script
 
 # Language:     Vim script
 # Maintainer:   github user lacygoill
-# Last Change:  2024 Nov 08
+# Last Change:  2024 Dec 26
 #
 # Includes changes from The Vim Project:
 #  - 2024 Feb 09: Fix indent after literal Dict (A. Radev via #13966)
 #  - 2024 Nov 08: Fix indent after :silent! function (D. Kearns via #16009)
+#  - 2024 Dec 26: Fix indent for enums (Jim Zhou via #16293)
 
 # NOTE: Whenever you change the code, make sure the tests are still passing:
 #
@@ -172,6 +173,7 @@ const MODIFIERS: dict<string> = {
     def: ['export', 'static'],
     class: ['export', 'abstract', 'export abstract'],
     interface: ['export'],
+    enum: ['export'],
 }
 #     ...
 #     class: ['export', 'abstract', 'export abstract'],
@@ -634,6 +636,7 @@ def Offset( # {{{2
     elseif !line_A.isfirst
             && (line_B->EndsWithLineContinuation()
             || line_A.text =~ LINE_CONTINUATION_AT_SOL)
+            && !(line_B->EndsWithComma() && line_A.lnum->IsInside('EnumBlock'))
         return shiftwidth()
     endif
 
@@ -1051,6 +1054,22 @@ def ContinuesBelowBracketBlock( # {{{3
 enddef
 
 def IsInside(lnum: number, syntax: string): bool # {{{3
+    if syntax == 'EnumBlock'
+        var cur_pos = getpos('.')
+        cursor(lnum, 1)
+        var enum_pos = search('^\C\s*\%(export\s\)\=\s*enum\s\+\S\+', 'bnW')
+        var endenum_pos = search('^\C\s*endenum\>', 'bnW')
+        setpos('.', cur_pos)
+
+        if enum_pos == 0 && endenum_pos == 0
+            return false
+        endif
+        if (enum_pos > 0 && (endenum_pos == 0 || enum_pos > endenum_pos))
+            return true
+        endif
+        return false
+    endif
+
     if !exists('b:vimindent')
             || !b:vimindent->has_key($'is_{syntax}')
         return false
diff --git a/runtime/indent/testdir/vim.in b/runtime/indent/testdir/vim.in
index ae52f3a94..431528ee2 100644
--- a/runtime/indent/testdir/vim.in
+++ b/runtime/indent/testdir/vim.in
@@ -947,6 +947,20 @@ Black
 endenum
 " END_INDENT
 
+" START_INDENT
+enum Digits
+INVALID(v:numbermax),  # The null value.
+ZERO(0 * v:numbermin), ONE(2 - 1),
+TWO(1 + 1), THREE(9 / 3), FOUR(1 * 4),
+FIVE(1 + 2 + 2), SIX(36 / 3 / 2), SEVEN(7), EIGHT(2 * 2 * 2),
+NINE(3 + 3 + 3)
+const value: number
+def new(value: number)
+this.value = value
+enddef
+endenum
+" END_INDENT
+
 " START_INDENT
 call prop_type_add('indent_after_literal_dict', #{ foo: 'bar' })
 call prop_type_delete('indent_after_literal_dict')
diff --git a/runtime/indent/testdir/vim.ok b/runtime/indent/testdir/vim.ok
index 2ab4f39c0..03001d525 100644
--- a/runtime/indent/testdir/vim.ok
+++ b/runtime/indent/testdir/vim.ok
@@ -940,10 +940,24 @@ endinterface
 " START_INDENT
 enum Color
     White,
-       Red,
-       Green,
-       Blue,
-       Black
+    Red,
+    Green,
+    Blue,
+    Black
+endenum
+" END_INDENT
+
+" START_INDENT
+enum Digits
+    INVALID(v:numbermax),  # The null value.
+    ZERO(0 * v:numbermin), ONE(2 - 1),
+    TWO(1 + 1), THREE(9 / 3), FOUR(1 * 4),
+    FIVE(1 + 2 + 2), SIX(36 / 3 / 2), SEVEN(7), EIGHT(2 * 2 * 2),
+    NINE(3 + 3 + 3)
+    const value: number
+    def new(value: number)
+       this.value = value
+    enddef
 endenum
 " END_INDENT
 

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/vim_dev/E1tQkQQ-004itB-VJ%40256bit.org.

Raspunde prin e-mail lui