Skip to content

Commit 4ba70ca

Browse files
authored
runtime(vim): Update base-syntax, fix nested function folding (#14397)
Only match function folding start and end patterns at the start of a line, excluding heredocs and :append/:change/:insert commands. Fixes #14393 Signed-off-by: Christian Brabandt <cb@256bit.org> Signed-off-by: Doug Kearns <dougkearns@gmail.com>
1 parent c59a864 commit 4ba70ca

41 files changed

Lines changed: 581 additions & 77 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

runtime/syntax/generator/vim.vim.base

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
" Maintainer: Hirohito Higashi <h.east.727 ATMARK gmail.com>
44
" Doug Kearns <dougkearns@gmail.com>
55
" URL: https://github.com/vim-jp/syntax-vim-ex
6-
" Last Change: 2024 Apr 12
6+
" Last Change: 2024 Apr 13
77
" Former Maintainer: Charles E. Campbell
88

99
" DO NOT CHANGE DIRECTLY.
@@ -191,9 +191,9 @@ syn cluster vimExprList contains=vimEnvvar,vimFunc,vimFuncVar,vimNumber,vimOper,
191191
" (buftype != nofile test avoids having append, change, insert show up in the command window)
192192
" =======================
193193
if &buftype != 'nofile'
194-
syn region vimInsert matchgroup=vimCommand start="^[: \t]*\(\d\+\(,\d\+\)\=\)\=a\%[ppend]$" matchgroup=vimCommand end="^\.$""
195-
syn region vimInsert matchgroup=vimCommand start="^[: \t]*\(\d\+\(,\d\+\)\=\)\=c\%[hange]$" matchgroup=vimCommand end="^\.$""
196-
syn region vimInsert matchgroup=vimCommand start="^[: \t]*\(\d\+\(,\d\+\)\=\)\=i\%[nsert]$" matchgroup=vimCommand end="^\.$""
194+
syn region vimInsert matchgroup=vimCommand start="^[: \t]*\(\d\+\(,\d\+\)\=\)\=a\%[ppend]$" matchgroup=vimCommand end="^\.$" extend
195+
syn region vimInsert matchgroup=vimCommand start="^[: \t]*\(\d\+\(,\d\+\)\=\)\=c\%[hange]$" matchgroup=vimCommand end="^\.$" extend
196+
syn region vimInsert matchgroup=vimCommand start="^[: \t]*\(\d\+\(,\d\+\)\=\)\=i\%[nsert]$" matchgroup=vimCommand end="^\.$" extend
197197
endif
198198

199199
" Behave! {{{2
@@ -244,12 +244,14 @@ if !exists("g:vimsyn_noerror") && !exists("g:vimsyn_noopererror")
244244
syn match vimOperError ")"
245245
endif
246246

247-
" Functions : Tag is provided for those who wish to highlight tagged functions {{{2
247+
" Functions: Tag is provided for those who wish to highlight tagged functions {{{2
248248
" =========
249249
syn cluster vimFuncList contains=vimFuncBang,vimFunctionError,vimFuncKey,vimFuncSID,Tag
250250
syn cluster vimDefList contains=vimFuncBang,vimFunctionError,vimDefKey,vimFuncSID,Tag
251-
syn cluster vimFuncBodyList contains=@vimCmdList,vimCmplxRepeat,vimComment,vimContinue,vimCtrlChar,vimDef,vimEnvvar,vimFBVar,vimFunc,vimFunction,vimFuncVar,vimLetHereDoc,vimLineComment,vimNotation,vimNotFunc,vimNumber,vimOper,vimOperParen,vimRegion,vimRegister,vimSearch,vimSpecFile,vimString,vimSubst
252-
syn cluster vimDefBodyList contains=@vimCmdList,vimCmplxRepeat,vim9Comment,vimContinue,vimCtrlChar,vimDef,vimEnvvar,vimFBVar,vimFunc,vimFunction,vimLetHereDoc,vim9LineComment,vimNotation,vimNotFunc,vimNumber,vimOper,vimOperParen,vimRegion,vimRegister,vimSearch,vimSpecFile,vimString,vimSubst
251+
252+
syn cluster vimFuncBodyCommon contains=@vimCmdList,vimCmplxRepeat,vimContinue,vimCtrlChar,vimDef,vimEnvvar,vimFBVar,vimFunc,vimFunction,vimLetHereDoc,vimNotation,vimNotFunc,vimNumber,vimOper,vimOperParen,vimRegister,vimSearch,vimSpecFile,vimString,vimSubst,vimFuncFold
253+
syn cluster vimFuncBodyList contains=@vimFuncBodyCommon,vimComment,vimLineComment,vimFuncVar,vimInsert
254+
syn cluster vimDefBodyList contains=@vimFuncBodyCommon,vim9Comment,vim9LineComment
253255

254256
syn region vimFuncPattern contained matchgroup=vimOper start="/" end="$" contains=@vimSubstList
255257
syn match vimFunction "\<fu\%[nction]\>" skipwhite nextgroup=vimCmdSep,vimComment,vimFuncPattern contains=vimFuncKey
@@ -284,9 +286,9 @@ syn match vimEndfunction "\<endf\%[unction]\>"
284286
syn match vimEnddef "\<enddef\>"
285287

286288
if exists("g:vimsyn_folding") && g:vimsyn_folding =~# 'f'
287-
syn region vimFuncFold start="\<fu\%[nction]\>!\=\s*\%(<[sS][iI][dD]>\|[sg]:\)\=\%(\i\|[#.]\|{.\{-1,}}\)\+\s*(" end="\<endf\%[unction]\>" contains=vimFunction fold keepend transparent
288-
syn region vimFuncFold start="\<def\>!\=\s*\%(<[sS][iI][dD]>\|[sg]:\)\=\%(\i\|[#.]\)\+(" end="\<enddef\>" contains=vimDef fold keepend transparent
289-
syn region vimFuncFold start="\<def\s\+new\i\+(" end="\<enddef\>" contains=vimDef fold keepend transparent
289+
syn region vimFuncFold start="^\s*:\=\s*fu\%[nction]\>!\=\s*\%(<[sS][iI][dD]>\|[sg]:\)\=\%(\i\|[#.]\|{.\{-1,}}\)\+\s*(" end="^\s*:\=\s*endf\%[unction]\>" contains=vimFunction fold keepend extend transparent
290+
syn region vimFuncFold start="^\s*:\=\s*def\>!\=\s*\%(<[sS][iI][dD]>\|[sg]:\)\=\%(\i\|[#.]\)\+(" end="^\s*:\=\s*enddef\>" contains=vimDef fold keepend extend transparent
291+
syn region vimFuncFold start="^\s*:\=\s*def\s\+new\i\+(" end="^\s*:\=\s*enddef\>" contains=vimDef fold keepend extend transparent
290292
endif
291293

292294
syn match vimFuncVar contained "a:\%(\K\k*\|\d\+\)\>"
@@ -502,7 +504,7 @@ syn keyword vimUnlet unl[et] skipwhite nextgroup=vimUnletBang,vimUnletVars
502504
syn match vimUnletBang contained "!" skipwhite nextgroup=vimUnletVars
503505
syn region vimUnletVars contained start="$\I\|\h" skip="\n\s*\\" end="$" end="|" contains=vimVar,vimEnvvar,vimContinue,vimString,vimNumber
504506

505-
VimFoldh syn region vimLetHereDoc matchgroup=vimLetHereDocStart start='=<<\s*\%(trim\s\+\%(eval\s\+\)\=\|eval\s\+\%(trim\s\+\)\=\)\=\z(\L\S*\)' matchgroup=vimLetHereDocStop end='^\s*\z1\s*$'
507+
VimFoldh syn region vimLetHereDoc matchgroup=vimLetHereDocStart start='=<<\s*\%(trim\s\+\%(eval\s\+\)\=\|eval\s\+\%(trim\s\+\)\=\)\=\z(\L\S*\)' matchgroup=vimLetHereDocStop end='^\s*\z1\s*$' extend
506508
syn keyword vimLet var skipwhite nextgroup=vimVar,vimFuncVar,vimLetHereDoc
507509

508510
" For: {{{2

runtime/syntax/testdir/dumps/vim_ex_def_fold_01.dump

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@
1717
| +0#0000000#ffffff0@74
1818
|++0#0000e05#a8a8a8255|-@1| @1|3| |l|i|n|e|s|:| |d|e|f|!| |F|o@1|(|)|:| |n|u|m|b|e|r|-@42
1919
| +0#0000000#ffffff0@74
20-
@57|1|9|,|1| @9|1|6|%|
20+
@57|1|9|,|1| @9|1|2|%|

runtime/syntax/testdir/dumps/vim_ex_def_fold_02.dump

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@
1717
| +0#0000000#ffffff0@74
1818
|"+0#0000e05&| |s|a|m|e| |n|a|m|e| |a|s| |a|n| |E|x| |c|o|m@1|a|n|d| +0#0000000&@46
1919
|++0#0000e05#a8a8a8255|-@1| @1|2| |l|i|n|e|s|:| |d|e|f| |s|:|l|s|(|)|-@50
20-
| +0#0000000#ffffff0@56|3|7|,|1| @9|3|4|%|
20+
| +0#0000000#ffffff0@56|3|7|,|1| @9|2|7|%|

runtime/syntax/testdir/dumps/vim_ex_def_fold_03.dump

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@
1717
| +0#0000000#ffffff0@74
1818
|++0#0000e05#a8a8a8255|-@1| @1|2| |l|i|n|e|s|:| |d|e|f| |F|o@1|(|)|:| |l|i|s|t|<|d|i|c|t|<|n|u|m|b|e|r|>@1|-@31
1919
| +0#0000000#ffffff0@74
20-
@57|5@1|,|1| @9|5@1|%|
20+
@57|5@1|,|1| @9|4@1|%|

runtime/syntax/testdir/dumps/vim_ex_def_fold_04.dump

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@
1717
|++0#0000e05#a8a8a8255|-@1| @1|2| |l|i|n|e|s|:| |d|e|f| |F|o@1|(|)|-@51
1818
| +0#0000000#ffffff0@74
1919
@75
20-
@57|7|3|,|1| @9|7@1|%|
20+
@57|7|3|,|1| @9|6|2|%|

runtime/syntax/testdir/dumps/vim_ex_def_fold_05.dump

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@
1515
@75
1616
|++0#0000e05#a8a8a8255|-@1| @1|4| |l|i|n|e|s|:| |d|e|f| |F|o@1|(|)|-@51
1717
| +0#0000000#ffffff0@74
18-
|~+0#4040ff13&| @73
19-
|~| @73
20-
| +0#0000000&@56|9|1|,|0|-|1| @7|B|o|t|
18+
@75
19+
|"+0#0000e05&| |f|o|l|d|-|r|e|g|i|o|n| |e|n|d|i|n|g| +0#0000000&@54
20+
@57|9|1|,|0|-|1| @7|8|2|%|
Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
| +0&#ffffff0@74
2-
|++0#0000e05#a8a8a8255|-@1| @1|2| |l|i|n|e|s|:| |d|e|f| |F|o@1|(|)|-@51
3-
| +0#0000000#ffffff0@74
4-
@75
5-
|"+0#0000e05&| |p|a|r|a|m|e|t|e|r|s| +0#0000000&@62
6-
> @74
7-
|++0#0000e05#a8a8a8255|-@1| @1|2| |l|i|n|e|s|:| |d|e|f| |F|o@1|(|x|:| |b|o@1|l|,| |y| |=| |4|2|,| |z|:| |s|t|r|i|n|g| |=| |"|z|e|d|"|)|-@17
8-
| +0#0000000#ffffff0@74
91
|++0#0000e05#a8a8a8255|-@1| @1|5| |l|i|n|e|s|:| |d|e|f| |F|o@1|(|-@52
102
| +0#0000000#ffffff0@74
113
@75
124
|"+0#0000e05&| |c|o|m@1|e|n|t|s| +0#0000000&@64
135
@75
14-
|++0#0000e05#a8a8a8255|-@1| @1|4| |l|i|n|e|s|:| |d|e|f| |F|o@1|(|)|-@51
6+
>++0#0000e05#a8a8a8255|-@1| @1|4| |l|i|n|e|s|:| |d|e|f| |F|o@1|(|)|-@51
7+
| +0#0000000#ffffff0@74
8+
@75
9+
|"+0#0000e05&| |f|o|l|d|-|r|e|g|i|o|n| |e|n|d|i|n|g| +0#0000000&@54
10+
@75
11+
|++0#0000e05#a8a8a8255|-@1| @1|3| |l|i|n|e|s|:| |d|e|f| |F|o@1|(|)|-@51
12+
| +0#0000000#ffffff0@74
13+
|++0#0000e05#a8a8a8255|-@1| @1|3| |l|i|n|e|s|:| |d|e|f| |F|o@1|(|)|-@51
14+
| +0#0000000#ffffff0@74
15+
|++0#0000e05#a8a8a8255|-@1| @1|5| |l|i|n|e|s|:| |d|e|f| |F|o@1|(|)|-@51
16+
| +0#0000000#ffffff0@74
17+
|++0#0000e05#a8a8a8255|-@1| @1|2| |l|i|n|e|s|:| |:|d|e|f| |F|o@1|(|)|-@50
1518
| +0#0000000#ffffff0@74
1619
|~+0#4040ff13&| @73
17-
|~| @73
18-
|~| @73
19-
|~| @73
20-
| +0#0000000&@56|1|0|9|,|0|-|1| @6|B|o|t|
20+
| +0#0000000&@56|1|0|9|,|1| @8|B|o|t|
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
|++0#0000e05#a8a8a8255|-@1| @1|3| |l|i|n|e|s|:| |d|e|f| |F|o@1|(|)|-@51
2+
| +0#0000000#ffffff0@74
3+
|++0#0000e05#a8a8a8255|-@1| @1|3| |l|i|n|e|s|:| |d|e|f| |F|o@1|(|)|-@51
4+
| +0#0000000#ffffff0@74
5+
|++0#0000e05#a8a8a8255|-@1| @1|5| |l|i|n|e|s|:| |d|e|f| |F|o@1|(|)|-@51
6+
> +0#0000000#ffffff0@74
7+
|++0#0000e05#a8a8a8255|-@1| @1|2| |l|i|n|e|s|:| |:|d|e|f| |F|o@1|(|)|-@50
8+
| +0#0000000#ffffff0@74
9+
|~+0#4040ff13&| @73
10+
|~| @73
11+
|~| @73
12+
|~| @73
13+
|~| @73
14+
|~| @73
15+
|~| @73
16+
|~| @73
17+
|~| @73
18+
|~| @73
19+
|~| @73
20+
| +0#0000000&@56|1|2|7|,|0|-|1| @6|B|o|t|
Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
| +0&#ffffff0@74
2-
|++0#0000e05#a8a8a8255|-@1| @1|3| |l|i|n|e|s|:| |d|e|f| |F|o@1|(|)|-@51
3-
| +0#0000000#ffffff0@74
4-
|++0#0000e05#a8a8a8255|-@1| @1|2| |l|i|n|e|s|:| |d|e|f| |F|o@1|(|)|-@51
5-
| +0#0000000#ffffff0@74
6-
|++0#0000e05#a8a8a8255|-@1| @1|2| |l|i|n|e|s|:| |d|e|f| |F|o@1|(|)|-@51
7-
| +0#0000000#ffffff0@74
8-
@75
9-
|"+0#0000e05&| |p|a|r|a|m|e|t|e|r|s| +0#0000000&@62
10-
@75
11-
|++0#0000e05#a8a8a8255|-@1| @1|2| |l|i|n|e|s|:| |d|e|f| |F|o@1|(|x|:| |b|o@1|l|,| |y| |=| |4|2|,| |z|:| |s|t|r|i|n|g| |=| |"|z|e|d|"|)|-@17
12-
| +0#0000000#ffffff0@74
132
|++0#0000e05#a8a8a8255|-@1| @1|5| |l|i|n|e|s|:| |d|e|f| |F|o@1|(|-@52
143
| +0#0000000#ffffff0@74
154
@75
165
|"+0#0000e05&| |c|o|m@1|e|n|t|s| +0#0000000&@64
176
@75
187
|++0#0000e05#a8a8a8255|-@1| @1|4| |l|i|n|e|s|:| |d|e|f| |F|o@1|(|)|-@51
8+
| +0#0000000#ffffff0@74
9+
@75
10+
|"+0#0000e05&| |f|o|l|d|-|r|e|g|i|o|n| |e|n|d|i|n|g| +0#0000000&@54
11+
@75
12+
|++0#0000e05#a8a8a8255|-@1| @1|3| |l|i|n|e|s|:| |d|e|f| |F|o@1|(|)|-@51
13+
| +0#0000000#ffffff0@74
14+
|++0#0000e05#a8a8a8255|-@1| @1|3| |l|i|n|e|s|:| |d|e|f| |F|o@1|(|)|-@51
15+
| +0#0000000#ffffff0@74
16+
|++0#0000e05#a8a8a8255|-@1| @1|5| |l|i|n|e|s|:| |d|e|f| |F|o@1|(|)|-@51
17+
| +0#0000000#ffffff0@74
18+
|++0#0000e05#a8a8a8255|-@1| @1|2| |l|i|n|e|s|:| |:|d|e|f| |F|o@1|(|)|-@50
1919
> +0#0000000#ffffff0@74
20-
@57|1@1|0|,|0|-|1| @6|B|o|t|
20+
@57|1|3|0|,|0|-|1| @6|B|o|t|
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
>v+0#af5f00255#ffffff0|i|m|9|s|c|r|i|p|t| +0#0000000&@64
2+
|#+0#0000e05&| |V|i|m|9| |:|d|e|f| |c|o|m@1|a|n|d| |(|n|e|s|t|e|d|)| +0#0000000&@46
3+
@75
4+
|c+0#af5f00255&|l|a|s@1| +0#0000000&|T|e|s|t| @64
5+
@4|c+0#af5f00255&|o|n|s|t| +0#0000000&|n+0#00e0e07&|a|m|e|:+0#0000000&| |s|t|r|i|n|g| @52
6+
@75
7+
@4|d+0#af5f00255&|e|f| +0#0000000&|n|e|w|(+0#e000e06&|)| +0#0000000&@61
8+
@8|d+0#af5f00255&|e|f| +0#0000000&|N|a|m|e|(+0#e000e06&|)|:+0#0000000&| |s+0#00e0003&|t|r|i|n|g| +0#0000000&@48
9+
@12|f+0#af5f00255&|u|n|c|t|i|o|n| +0#0000000&|G|i|v|e|N|a|m|e|(+0#e000e06&|)| +0#0000000&@43
10+
@16|r+0#af5f00255&|e|t|u|r|n| +0#0000000&|"+0#e000002&|a|n|y|"| +0#0000000&@46
11+
@12|e+0#af5f00255&|n|d|f|u|n|c|t|i|o|n| +0#0000000&@51
12+
@75
13+
@12|r+0#af5f00255&|e|t|u|r|n| +0#0000000&|G|i|v|e|N|a|m|e|(+0#e000e06&|)| +0#0000000&@45
14+
@8|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@60
15+
@75
16+
@8|t+0#af5f00255&|h|i|s|.|n+0#0000000&|a|m|e| |=+0#af5f00255&| +0#0000000&|N|a|m|e|(+0#e000e06&|)| +0#0000000&@48
17+
@4|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@64
18+
|e+0#af5f00255&|n|d|c|l|a|s@1| +0#0000000&@66
19+
@75
20+
@57|1|,|1| @10|T|o|p|

0 commit comments

Comments
 (0)