]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
runtime(vim): Update base syntax, fix Vim9 :for loop variable highlighting
authorDoug Kearns <dougkearns@gmail.com>
Sun, 31 Aug 2025 17:13:32 +0000 (19:13 +0200)
committerChristian Brabandt <cb@256bit.org>
Sun, 31 Aug 2025 17:13:32 +0000 (19:13 +0200)
Highlight the iteration variable's type in Vim9 :for {var} loops.

Reported by Aliaksei Budavei.

fixes: #17961
closes: #18163

Signed-off-by: Doug Kearns <dougkearns@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
runtime/syntax/generator/vim.vim.base
runtime/syntax/testdir/dumps/vim9_ex_for_01.dump
runtime/syntax/testdir/dumps/vim9_ex_for_02.dump
runtime/syntax/testdir/dumps/vim9_ex_for_03.dump
runtime/syntax/testdir/dumps/vim9_ex_for_04.dump [new file with mode: 0644]
runtime/syntax/testdir/dumps/vim9_ex_for_05.dump [new file with mode: 0644]
runtime/syntax/testdir/input/vim9_ex_for.vim
runtime/syntax/vim.vim

index 9f5781c2f4fbc85365d89788d0f62170a40df109..2d89ce5ca79d1f588b58e1a5e599f3a08c2486e2 100644 (file)
@@ -1172,7 +1172,7 @@ syn region        vimFor
       \ matchgroup=vimCommand
       \ start="\<for\>" end="\<in\>"
       \ skipwhite skipnl nextgroup=@vimForInContinue,vim9ForInComment,@vimExprList
-      \ contains=@vimContinue,vimVar,vimVarList,vim9VariableList
+      \ contains=@vimContinue,vimVar,vimVarList,vim9Variable,vim9VariableList
       \ transparent
 
 syn match      vim9ForInComment                contained       "#.*"   skipwhite skipempty nextgroup=vimForInComment,@vimExprList
index 5cf763707c0690f0e669833bb9d52611e743a5f1..1335c9fa7ec0e54711701fb79f61bb1351816618 100644 (file)
@@ -15,6 +15,6 @@
 @75
 |f+0#af5f00255&|o|r| +0#0000000&|f+0#00e0e07&|o@1| +0#0000000&|i+0#af5f00255&|n| +0#0000000&|[+0#e000e06&|4+0#e000002&|2|]+0#e000e06&| +0#0000000&||| |e+0#af5f00255&|c|h|o| +0#0000000&|f+0#00e0e07&|o@1| +0#0000000&||| |e+0#af5f00255&|n|d|f|o|r| +0#0000000&@39
 @75
-|f+0#af5f00255&|o|r| +0#0000000&|f+0#00e0e07&|o@1|:+0#0000000&| |n+0#00e0e07&|u|m|b|e|r| +0#0000000&|i+0#af5f00255&|n| +0#0000000&|[+0#e000e06&|4+0#e000002&|2|]+0#e000e06&| +0#0000000&||| |e+0#af5f00255&|c|h|o| +0#0000000&|f+0#00e0e07&|o@1| +0#0000000&||| |e+0#af5f00255&|n|d|f|o|r| +0#0000000&@31
+|f+0#af5f00255&|o|r| +0#0000000&|f+0#00e0e07&|o@1|:+0#0000000&| |n+0#00e0003&|u|m|b|e|r| +0#0000000&|i+0#af5f00255&|n| +0#0000000&|[+0#e000e06&|4+0#e000002&|2|]+0#e000e06&| +0#0000000&||| |e+0#af5f00255&|c|h|o| +0#0000000&|f+0#00e0e07&|o@1| +0#0000000&||| |e+0#af5f00255&|n|d|f|o|r| +0#0000000&@31
 @75
-@57|1|9|,|7| @9|2|7|%| 
+@57|1|9|,|7| @9|1|8|%| 
index 9e60ec45ba1ee96c3b0d99ba4a80865e3ad9e967..9b0f7f18608a4e6626093ee8c523080eee3834b3 100644 (file)
@@ -17,4 +17,4 @@
 |e+0#af5f00255&|n|d|f|o|r| +0#0000000&@68
 @75
 |f+0#af5f00255&|o|r| +0#0000000&|[|f+0#00e0e07&|o@1|,+0#0000000&| |b+0#00e0e07&|a|r|]+0#0000000&| |i+0#af5f00255&|n| +0#0000000&@57
-@57|3|7|,|0|-|1| @7|6|4|%| 
+@57|3|7|,|0|-|1| @7|4@1|%| 
index 1aecb92bbbaa6c7ee8f3a8aff26b9691747ffb02..7b813bc343c6232e7fcf50a36f9ea90c708b685f 100644 (file)
@@ -16,5 +16,5 @@
 @2|e+0#af5f00255&|c|h|o| +0#0000000&|f+0#00e0e07&|o@1| +0#0000000&|b+0#00e0e07&|a|r| +0#0000000&@60
 |e+0#af5f00255&|n|d|f|o|r| +0#0000000&@68
 @75
-|~+0#4040ff13&| @73
-| +0#0000000&@56|5@1|,|0|-|1| @7|B|o|t
+@75
+@57|5@1|,|0|-|1| @7|7|1|%
diff --git a/runtime/syntax/testdir/dumps/vim9_ex_for_04.dump b/runtime/syntax/testdir/dumps/vim9_ex_for_04.dump
new file mode 100644 (file)
index 0000000..9d4db8f
--- /dev/null
@@ -0,0 +1,20 @@
+| +0&#ffffff0@74
+|#+0#0000e05&| |I|s@1|u|e| |#|7|9|6|1| |(|B|u|i|l|t|i|n| |t|y|p|e|s| |a|r|e| |n|o|t| |h|i|g|h|l|i|g|h|t|e|d| |i|n| |i|t|e|m|-|v|a|r|i|a|b|l|e| |d|e|c|l|a|r|a|t|i
+|o|n|s| +0#0000000&@71
+|#+0#0000e05&| @13|o|f| |:|f|o|r| |c|o|m@1|a|n|d|s|)| +0#0000000&@42
+@75
+>v+0#af5f00255&|a|r| +0#0000000&|m+0#00e0e07&|:+0#0000000&| |n+0#00e0003&|u|m|b|e|r| +0#0000000&@61
+|v+0#af5f00255&|a|r| +0#0000000&|n+0#00e0e07&|:+0#0000000&| |n+0#00e0003&|u|m|b|e|r| +0#0000000&@61
+|f+0#af5f00255&|o|r| +0#0000000&|x+0#00e0e07&|:+0#0000000&| |n+0#00e0003&|u|m|b|e|r| +0#0000000&|i+0#af5f00255&|n| +0#0000000&|r+0#00e0e07&|a|n|g|e|(+0#e000e06&|2+0#e000002&|)+0#e000e06&| +0#0000000&||| |m+0#af5f00255&| +0#0000000&|=+0#af5f00255&| +0#0000000&|x+0#00e0e07&| +0#0000000&||| |e+0#af5f00255&|n|d|f|o|r| +0#0000000&@32
+|#+0#0000e05&@5| |^@5| +0#0000000&@61
+|e+0#af5f00255&|c|h|o| +0#0000000&|m+0#00e0e07&| +0#0000000&@68
+|f+0#af5f00255&|o|r| +0#0000000&|[|x+0#00e0e07&|:+0#0000000&| |n+0#00e0003&|u|m|b|e|r|,+0#0000000&| |y+0#00e0e07&|:+0#0000000&| |n+0#00e0003&|u|m|b|e|r|]+0#0000000&| |i+0#af5f00255&|n| +0#0000000&|[+0#e000e06&@1|0+0#e000002&|,+0#0000000&| |0+0#e000002&|]+0#e000e06&|,+0#0000000&| |[+0#e000e06&|1+0#e000002&|,+0#0000000&| |1+0#e000002&|]+0#e000e06&@1| +0#0000000&||| |[|m+0#00e0e07&|,+0#0000000&| |n+0#00e0e07&|]+0#0000000&| |=+0#af5f00255&| +0#0000000&|[+0#e000e06&|x+0#00e0e07&|,+0#0000000&| |y+0#00e0e07&|]+0#e000e06&| +0#0000000&||| |e+0#af5f00255&|n|d|f|o|r| +0#0000000&@1
+|e+0#af5f00255&|c|h|o| +0#0000000&|m+0#00e0e07&| +0#0000000&|n+0#00e0e07&| +0#0000000&@66
+@75
+|v+0#af5f00255&|a|r| +0#0000000&|F+0#00e0e07&|:+0#0000000&| |f+0#00e0003&|u|n|c| +0#0000000&@63
+|f+0#af5f00255&|o|r| +0#0000000&|t+0#00e0e07&|:+0#0000000&| |t+0#00e0003&|u|p|l|e|<|f|u|n|c|>| +0#0000000&|i+0#af5f00255&|n| +0#0000000&|(+0#e000e06&@1|f+0#00e0e07&|u|n|c|t|i|o|n|(+0#e000e06&|'+0#e000002&|t|o|l|o|w|e|r|'|)+0#e000e06&|,+0#0000000&|)+0#e000e06&|,+0#0000000&|)+0#e000e06&| +0#0000000&||| |F| |=+0#af5f00255&| +0#0000000&|t+0#00e0e07&|[+0#0000000&|0+0#e000002&|]+0#0000000&| ||| |e+0#af5f00255&|n|d|f|o|r| +0#0000000&@7
+|#+0#0000e05&@5| |^@10| +0#0000000&@56
+|e+0#af5f00255&|c|h|o| +0#0000000&|F|(+0#e000e06&|'+0#e000002&|H|E|L@1|O|'|)+0#e000e06&| +0#0000000&@59
+|f+0#af5f00255&|o|r| +0#0000000&|[|L+0#00e0e07&|:+0#0000000&| |f+0#00e0003&|u|n|c|,+0#0000000&| |U+0#00e0e07&|:+0#0000000&| |f+0#00e0003&|u|n|c|]+0#0000000&| |i+0#af5f00255&|n| +0#0000000&|[+0#e000e06&@1|f+0#00e0e07&|u|n|c|t|i|o|n|(+0#e000e06&|'+0#e000002&|t|o|l|o|w|e|r|'|)+0#e000e06&|,+0#0000000&| |f+0#00e0e07&|u|n|c|t|i|o|n|(+0#e000e06&|'+0#e000002&|t|o|u|p@1|e|r|'|)+0#e000e06&|]@1| +0#0000000&@4
+@4|[|_+0#00e0e07&|,+0#0000000&| |F+0#00e0e07&|]+0#0000000&| |=+0#af5f00255&| +0#0000000&|[+0#e000e06&|L+0#00e0e07&|,+0#0000000&| |U+0#00e0e07&|]+0#e000e06&| +0#0000000&@55
+@57|7|2|,|1| @9|9|5|%| 
diff --git a/runtime/syntax/testdir/dumps/vim9_ex_for_05.dump b/runtime/syntax/testdir/dumps/vim9_ex_for_05.dump
new file mode 100644 (file)
index 0000000..8e6c2e7
--- /dev/null
@@ -0,0 +1,20 @@
+| +0&#ffffff0@3|[|_+0#00e0e07&|,+0#0000000&| |F+0#00e0e07&|]+0#0000000&| |=+0#af5f00255&| +0#0000000&|[+0#e000e06&|L+0#00e0e07&|,+0#0000000&| |U+0#00e0e07&|]+0#e000e06&| +0#0000000&@55
+|e+0#af5f00255&|n|d|f|o|r| +0#0000000&@68
+|e+0#af5f00255&|c|h|o| +0#0000000&|F|(+0#e000e06&|'+0#e000002&|h|e|l@1|o|'|)+0#e000e06&| +0#0000000&|F|(+0#e000e06&|'+0#e000002&|w|o|r|l|d|'|)+0#e000e06&| +0#0000000&@48
+> @74
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+| +0#0000000&@56|8@1|,|0|-|1| @7|B|o|t| 
index e01afc6c43a9ff97556800b03ea5ef696a5c4c0f..f23b3cc50508801d9ce3f7998e3492939b67bb6f 100644 (file)
@@ -65,3 +65,24 @@ for [foo: number, bar: number] in expr2
   echo foo bar
 endfor
 
+
+# Issue #7961 (Builtin types are not highlighted in item-variable declarations
+#              of :for commands)
+
+var m: number
+var n: number
+for x: number in range(2) | m = x | endfor
+###### ^^^^^^
+echo m
+for [x: number, y: number] in [[0, 0], [1, 1]] | [m, n] = [x, y] | endfor
+echo m n
+
+var F: func
+for t: tuple<func> in ((function('tolower'),),) | F = t[0] | endfor
+###### ^^^^^^^^^^^
+echo F('HELLO')
+for [L: func, U: func] in [[function('tolower'), function('toupper')]]
+    [_, F] = [L, U]
+endfor
+echo F('hello') F('world')
+
index 101cf350846d9201f501818539f6b49653ad1724..3b1afa8c1dd55ec0343283bc3ccbd66d459b944a 100644 (file)
@@ -1228,7 +1228,7 @@ syn region        vimFor
       \ matchgroup=vimCommand
       \ start="\<for\>" end="\<in\>"
       \ skipwhite skipnl nextgroup=@vimForInContinue,vim9ForInComment,@vimExprList
-      \ contains=@vimContinue,vimVar,vimVarList,vim9VariableList
+      \ contains=@vimContinue,vimVar,vimVarList,vim9Variable,vim9VariableList
       \ transparent
 
 syn match      vim9ForInComment                contained       "#.*"   skipwhite skipempty nextgroup=vimForInComment,@vimExprList