summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordkearns <dougkearns@gmail.com>2024-03-22 06:41:10 +1100
committerGitHub <noreply@github.com>2024-03-21 20:41:10 +0100
commit35e6f4ca27c8115c606f265e4b09e11db01c970d (patch)
tree47aa9cc4268a1cd31c8a9962462c4d7c723fbcf9
parent3a6bd0c5c743bf69d2e8af4c8b3c6b2cb5f3631a (diff)
runtime(vim): Update base-syntax, improve function definition highlighting (#14203)
Improve function definition highlighting. - Match bang and function modifiers - abort etc. - Only match valid scope modifiers. - Match listing commands. - Don't match ex commands in function names. - Split function syntax groups into :func and :def subgroups. - Match Vim9-script parameter and return types. - Limit legacy-script and Vim9-script comments to :func and :def definitions, respectively. Signed-off-by: Doug Kearns <dougkearns@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
-rw-r--r--runtime/syntax/generator/gen_syntax_vim.vim1
-rw-r--r--runtime/syntax/generator/vim.vim.base85
-rw-r--r--runtime/syntax/testdir/dumps/vim_ex_def_00.dump20
-rw-r--r--runtime/syntax/testdir/dumps/vim_ex_def_01.dump20
-rw-r--r--runtime/syntax/testdir/dumps/vim_ex_def_02.dump20
-rw-r--r--runtime/syntax/testdir/dumps/vim_ex_def_03.dump20
-rw-r--r--runtime/syntax/testdir/dumps/vim_ex_def_04.dump20
-rw-r--r--runtime/syntax/testdir/dumps/vim_ex_def_05.dump20
-rw-r--r--runtime/syntax/testdir/dumps/vim_ex_def_06.dump20
-rw-r--r--runtime/syntax/testdir/dumps/vim_ex_def_99.dump20
-rw-r--r--runtime/syntax/testdir/dumps/vim_ex_def_fold_00.dump20
-rw-r--r--runtime/syntax/testdir/dumps/vim_ex_def_fold_01.dump20
-rw-r--r--runtime/syntax/testdir/dumps/vim_ex_def_fold_02.dump20
-rw-r--r--runtime/syntax/testdir/dumps/vim_ex_def_fold_03.dump20
-rw-r--r--runtime/syntax/testdir/dumps/vim_ex_def_fold_04.dump20
-rw-r--r--runtime/syntax/testdir/dumps/vim_ex_def_fold_05.dump20
-rw-r--r--runtime/syntax/testdir/dumps/vim_ex_def_fold_06.dump20
-rw-r--r--runtime/syntax/testdir/dumps/vim_ex_def_fold_99.dump20
-rw-r--r--runtime/syntax/testdir/dumps/vim_ex_function_00.dump20
-rw-r--r--runtime/syntax/testdir/dumps/vim_ex_function_01.dump20
-rw-r--r--runtime/syntax/testdir/dumps/vim_ex_function_02.dump20
-rw-r--r--runtime/syntax/testdir/dumps/vim_ex_function_03.dump20
-rw-r--r--runtime/syntax/testdir/dumps/vim_ex_function_04.dump20
-rw-r--r--runtime/syntax/testdir/dumps/vim_ex_function_05.dump20
-rw-r--r--runtime/syntax/testdir/dumps/vim_ex_function_06.dump20
-rw-r--r--runtime/syntax/testdir/dumps/vim_ex_function_07.dump20
-rw-r--r--runtime/syntax/testdir/dumps/vim_ex_function_08.dump20
-rw-r--r--runtime/syntax/testdir/dumps/vim_ex_function_09.dump20
-rw-r--r--runtime/syntax/testdir/dumps/vim_ex_function_99.dump20
-rw-r--r--runtime/syntax/testdir/dumps/vim_ex_function_fold_00.dump20
-rw-r--r--runtime/syntax/testdir/dumps/vim_ex_function_fold_01.dump20
-rw-r--r--runtime/syntax/testdir/dumps/vim_ex_function_fold_02.dump20
-rw-r--r--runtime/syntax/testdir/dumps/vim_ex_function_fold_03.dump20
-rw-r--r--runtime/syntax/testdir/dumps/vim_ex_function_fold_04.dump20
-rw-r--r--runtime/syntax/testdir/dumps/vim_ex_function_fold_05.dump20
-rw-r--r--runtime/syntax/testdir/dumps/vim_ex_function_fold_06.dump20
-rw-r--r--runtime/syntax/testdir/dumps/vim_ex_function_fold_07.dump20
-rw-r--r--runtime/syntax/testdir/dumps/vim_ex_function_fold_08.dump20
-rw-r--r--runtime/syntax/testdir/dumps/vim_ex_function_fold_09.dump20
-rw-r--r--runtime/syntax/testdir/dumps/vim_ex_function_fold_99.dump20
-rw-r--r--runtime/syntax/testdir/dumps/vim_ex_syntax_09.dump4
-rw-r--r--runtime/syntax/testdir/dumps/vim_ex_syntax_99.dump4
-rw-r--r--runtime/syntax/testdir/input/vim_ex_def.vim125
-rw-r--r--runtime/syntax/testdir/input/vim_ex_def_fold.vim126
-rw-r--r--runtime/syntax/testdir/input/vim_ex_function.vim182
-rw-r--r--runtime/syntax/testdir/input/vim_ex_function_fold.vim183
-rw-r--r--runtime/syntax/vim.vim96
47 files changed, 1520 insertions, 46 deletions
diff --git a/runtime/syntax/generator/gen_syntax_vim.vim b/runtime/syntax/generator/gen_syntax_vim.vim
index 5c797deb7d..b4feeed790 100644
--- a/runtime/syntax/generator/gen_syntax_vim.vim
+++ b/runtime/syntax/generator/gen_syntax_vim.vim
@@ -279,6 +279,7 @@ function! s:get_vim_command_type(cmd_name)
\ 'autocmd', 'augroup', 'doautocmd', 'doautoall',
\ 'echo', 'echoconsole', 'echoerr', 'echohl', 'echomsg', 'echon', 'echowindow',
\ 'execute',
+ \ 'function', 'endfunction', 'def', 'enddef',
\ 'behave', 'augroup', 'normal', 'syntax',
\ 'append', 'insert',
\ 'Next', 'Print', 'X',
diff --git a/runtime/syntax/generator/vim.vim.base b/runtime/syntax/generator/vim.vim.base
index 46285f3dba..00041099d4 100644
--- a/runtime/syntax/generator/vim.vim.base
+++ b/runtime/syntax/generator/vim.vim.base
@@ -167,7 +167,7 @@ syn match vimNumber '\%(^\|\A\)\zs#\x\{6}' skipwhite nextgroup=vimGlobal,vimSub
syn case match
" All vimCommands are contained by vimIsCommand. {{{2
-syn cluster vimCmdList contains=vimAbb,vimAddress,vimAutoCmd,vimAugroup,vimBehave,@vimEcho,vimExecute,vimIsCommand,vimExtCmd,vimFunction,vimGlobal,vimHighlight,vimLet,vimMap,vimMark,vimNotFunc,vimNorm,vimSet,vimSyntax,vimUnlet,vimUnmap,vimUserCmd,vimMenu,vimMenutranslate
+syn cluster vimCmdList contains=vimAbb,vimAddress,vimAutoCmd,vimAugroup,vimBehave,vimDef,@vimEcho,vimEnddef,vimEndfunction,vimExecute,vimIsCommand,vimExtCmd,vimFor,vimFunction,vimGlobal,vimHighlight,vimLet,vimMap,vimMark,vimNotFunc,vimNorm,vimSet,vimSyntax,vimUnlet,vimUnmap,vimUserCmd,vimMenu,vimMenutranslate
syn match vimCmdSep "[:|]\+" skipwhite nextgroup=@vimCmdList,vimSubst1
syn match vimIsCommand "\<\%(\h\w*\|[23]mat\%[ch]\)\>" contains=vimCommand
syn match vimVar contained "\<\h[a-zA-Z0-9#_]*\>"
@@ -227,7 +227,7 @@ syn keyword vimAugroupKey contained aug[roup] skipwhite nextgroup=vimAugroupBan
" Operators: {{{2
" =========
-syn cluster vimOperGroup contains=vimEnvvar,vimFunc,vimFuncVar,vimOper,vimOperParen,vimNumber,vimString,vimType,vimRegister,@vimContinue,vim9Comment,vimVar
+syn cluster vimOperGroup contains=vimEnvvar,vimFunc,vimFuncVar,vimOper,vimOperParen,vimNumber,vimString,vimRegister,@vimContinue,vim9Comment,vimVar
syn match vimOper "||\|&&\|[-+*/%.!]" skipwhite nextgroup=vimString,vimSpecFile
syn match vimOper "\%#=1\(==\|!=\|>=\|<=\|=\~\|!\~\|>\|<\|=\|!\~#\)[?#]\{0,2}" skipwhite nextgroup=vimString,vimSpecFile
syn match vimOper "\(\<is\|\<isnot\)[?#]\{0,2}\>" skipwhite nextgroup=vimString,vimSpecFile
@@ -239,28 +239,67 @@ endif
" Functions : Tag is provided for those who wish to highlight tagged functions {{{2
" =========
-syn cluster vimFuncList contains=vimCommand,vimFunctionError,vimFuncKey,Tag,vimFuncSID
-syn cluster vimFuncBodyList contains=@vimCmdList,vimCmplxRepeat,vimComment,vim9Comment,vimContinue,vimCtrlChar,vimEnvvar,vimFBVar,vimFunc,vimFunction,vimFuncVar,vimLetHereDoc,vimLineComment,vimNotation,vimNotFunc,vimNumber,vimOper,vimOperParen,vimRegion,vimRegister,vimSearch,vimSpecFile,vimString,vimSubst
-syn match vimFunction "\<\(fu\%[nction]\)!\=\s\+\%(<[sS][iI][dD]>\|[sSgGbBwWtTlL]:\)\=\%(\i\|[#.]\|{.\{-1,}}\)*\ze\s*(" contains=@vimFuncList nextgroup=vimFuncBody
-syn match vimFunction "\<def\s\+new\i\{-}(" contains=@vimFuncList nextgroup=vimFuncBody
-syn match vimFunction "\<def!\=\s\+\%(\i\|[#.]\|{.\{-1,}}\)*\ze\s*(" contains=@vimFuncList nextgroup=vimFuncBody
-"syn match vimFunction "\<def!\=\ze\s*(" contains=@vimFuncList nextgroup=vimFuncBody
+syn cluster vimFuncList contains=vimFuncBang,vimFunctionError,vimFuncKey,vimFuncSID,Tag
+syn cluster vimDefList contains=vimFuncBang,vimFunctionError,vimDefKey,vimFuncSID,Tag
+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
+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
+
+syn region vimFuncPattern contained matchgroup=vimOper start="/" end="$" contains=@vimSubstList
+syn match vimFunction "\<fu\%[nction]\>" skipwhite nextgroup=vimCmdSep,vimComment,vimFuncPattern contains=vimFuncKey
+syn match vimDef "\<def\>" skipwhite nextgroup=vimCmdSep,vimComment,vimFuncPattern contains=vimDefKey
+
+syn match vimFunction "\<fu\%[nction]\>!\=\s*\%(<[sS][iI][dD]>\|[sg]:\)\=\%(\i\|[#.]\|{.\{-1,}}\)\+" contains=@vimFuncList skipwhite nextgroup=vimFuncParams
+syn match vimDef "\<def\s\+new\%(\i\|{.\{-1,}}\)\+" contains=@vimDefList nextgroup=vimDefParams
+syn match vimDef "\<def\>!\=\s*\%(<[sS][iI][dD]>\|[sg]:\)\=\%(\i\|[#.]\|{.\{-1,}}\)\+" contains=@vimDefList nextgroup=vimDefParams
+
+syn match vimFuncComment contained +".*+ skipwhite skipnl nextgroup=vimFuncBody,vimEndfunction
+syn match vimDefComment contained "#.*" skipwhite skipnl nextgroup=vimDefBody,vimEnddef
+
+syn match vimFuncBang contained "!"
+syn match vimFuncSID contained "\c<sid>"
+syn match vimFuncSID contained "\<[sg]:"
+syn keyword vimFuncKey contained fu[nction]
+syn keyword vimDefKey contained def
+
+syn region vimFuncParams contained matchgroup=Delimiter start="(" skip=+\n\s*\\\|\n\s*"\\ + end=")" skipwhite skipnl nextgroup=vimFuncBody,vimFuncComment,vimEndfunction,vimFuncMod contains=vimFuncParam,@vimContinue
+syn region vimDefParams contained matchgroup=Delimiter start="(" end=")" skipwhite skipnl nextgroup=vimDefBody,vimDefComment,vimEnddef,vimReturnType contains=vimDefParam,vim9Comment
+syn match vimFuncParam contained "\<\h\w*\>\|\.\.\." skipwhite nextgroup=vimFuncParamEquals
+syn match vimDefParam contained "\<\h\w*\>" skipwhite nextgroup=vimParamType,vimFuncParamEquals
+
+syn match vimFuncParamEquals contained "=" skipwhite nextgroup=@vimExprList
+syn match vimFuncMod contained "\<\%(abort\|closure\|dict\|range\)\>" skipwhite skipnl nextgroup=vimFuncBody,vimFuncComment,vimEndfunction,vimFuncMod
+
+syn region vimFuncBody contained start="^" matchgroup=vimCommand end="\<endfu\%[nction]\>" contains=@vimFuncBodyList
+syn region vimDefBody contained start="^" matchgroup=vimCommand end="\<enddef\>" contains=@vimDefBodyList
+
+syn match vimEndfunction "\<endf\%[unction]\>"
+syn match vimEnddef "\<enddef\>"
if exists("g:vimsyn_folding") && g:vimsyn_folding =~# 'f'
- syn region vimFuncBody contained fold start="\ze\s*(" matchgroup=vimCommand end="\<\(endf\>\|endfu\%[nction]\>\|enddef\>\)" contains=@vimFuncBodyList
-else
- syn region vimFuncBody contained start="\ze\s*(" matchgroup=vimCommand end="\<\(endf\>\|endfu\%[nction]\>\|enddef\>\)" contains=@vimFuncBodyList
+ syn region vimFuncFold start="\<fu\%[nction]\>!\=\s*\%(<[sS][iI][dD]>\|[sg]:\)\=\%(\i\|[#.]\|{.\{-1,}}\)\+\s*(" end="\<endf\%[unction]\>" contains=vimFunction fold keepend transparent
+ syn region vimFuncFold start="\<def\>!\=\s*\%(<[sS][iI][dD]>\|[sg]:\)\=\%(\i\|[#.]\|{.\{-1,}}\)\+(" end="\<enddef\>" contains=vimDef fold keepend transparent
+ syn region vimFuncFold start="\<def\s\+new\%(\i\|{.\{-1,}}\)\+(" end="\<enddef\>" contains=vimDef fold keepend transparent
endif
-syn match vimFuncVar contained "a:\(\K\k*\|\d\+\)"
-syn match vimFuncSID contained "\c<sid>\|\<s:"
-syn keyword vimFuncKey contained fu[nction]
-syn keyword vimFuncKey contained def
+
+syn match vimFuncVar contained "a:\%(\K\k*\|\d\+\)\>"
syn match vimFuncBlank contained "\s\+"
syn keyword vimPattern contained start skip end
+" Types: {{{2
+" =====
" vimTypes : new for vim9
-syn match vimType ":\s*\zs\<\(bool\|number\|float\|string\|blob\|list<\|dict<\|job\|channel\|func\)\>"
+syn region vimReturnType contained start=":\s" end="$" matchgroup=vim9Comment end="\ze#" skipwhite skipnl nextgroup=vimDefBody,vimDefComment,vimEnddef contains=vimTypeSep transparent
+syn match vimParamType contained ":\s\+\a" skipwhite skipnl nextgroup=vimFuncParamEquals contains=vimTypeSep,@vimType
+
+syn match vimTypeSep contained ":\s\@=" skipwhite nextgroup=@vimType
+syn keyword vimType contained any blob bool channel float job number string void
+syn match vimType contained "\<func\>"
+syn region vimCompoundType contained matchgroup=vimType start="\<func(" end=")" nextgroup=vimTypeSep contains=@vimType oneline transparent
+syn region vimCompoundType contained matchgroup=vimType start="\<\%(list\|dict\)<" end=">" contains=@vimType oneline transparent
+syn match vimUserType contained "\<\u\w*\>"
+
+syn cluster vimType contains=vimType,vimCompoundType,vimUserType
" Keymaps: (Vim Project Addition) {{{2
" =======
@@ -468,7 +507,7 @@ syn case ignore
syn keyword vimEchohlNone contained none
syn case match
-syn cluster vimEcho contains=vimEcho.*
+syn cluster vimEcho contains=vimEcho,vimEchohl
syn region vimExecute matchgroup=vimCommand start="\<exe\%[cute]\>" skip=+\\|\|\n\s*\\\|\n\s*"\\ + matchgroup=vimCmdSep end="|" excludenl end="$" contains=@vimContinue,@vimExprList transparent
@@ -552,7 +591,7 @@ syn match vimUsrCmd '^\s*\zs\u\%(\w*\)\@>\%([(#[]\|\s\+\%([-+*/%]\=\|\.\.\)=\)\@
" ====================
if !exists("g:vimsyn_noerror") && !exists("g:vimsyn_novimfunctionerror")
" TODO: The new-prefix exception should only apply to constructor definitions.
- syn match vimFunctionError "\s\zs\%(new\)\@![a-z0-9]\i\{-}\ze\s*(" contained contains=vimFuncKey,vimFuncBlank
+ syn match vimFunctionError "\s\zs\%(new\)\@![a-z0-9]\i\{-}\ze\s*(" contained contains=vimFuncKey,vimFuncBlank
syn match vimFunctionError "\s\zs\%(<[sS][iI][dD]>\|[sSgGbBwWtTlL]:\)\d\i\{-}\ze\s*(" contained contains=vimFuncKey,vimFuncBlank
syn match vimElseIfErr "\<else\s\+if\>"
syn match vimBufnrWarn /\<bufnr\s*(\s*["']\.['"]\s*)/
@@ -983,11 +1022,16 @@ if !exists("skip_vim_syntax_inits")
hi def link vimContinue Special
hi def link vimContinueComment vimComment
hi def link vimCtrlChar SpecialChar
+ hi def link vimDefComment vimComment
+ hi def link vimDefKey vimCommand
+ hi def link vimDefParam vimVar
hi def link vimEcho vimCommand
hi def link vimEchohlNone vimGroup
hi def link vimEchohl vimCommand
hi def link vimElseIfErr Error
hi def link vimElseif vimCondHL
+ hi def link vimEndfunction vimCommand
+ hi def link vimEnddef vimCommand
hi def link vimEnvvar PreProc
hi def link vimError Error
hi def link vimEscape Special
@@ -998,8 +1042,13 @@ if !exists("skip_vim_syntax_inits")
hi def link vimFor vimCommand
hi def link vimFTCmd vimCommand
hi def link vimFTOption vimSynType
+ hi def link vimFuncBang vimBang
+ hi def link vimFuncComment vimComment
hi def link vimFuncKey vimCommand
hi def link vimFuncName Function
+ hi def link vimFuncMod Special
+ hi def link vimFuncParam vimVar
+ hi def link vimFuncParamEquals vimOper
hi def link vimFuncSID Special
hi def link vimFuncVar Identifier
hi def link vimGroupAdd vimSynOption
diff --git a/runtime/syntax/testdir/dumps/vim_ex_def_00.dump b/runtime/syntax/testdir/dumps/vim_ex_def_00.dump
new file mode 100644
index 0000000000..4bc88584b5
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/vim_ex_def_00.dump
@@ -0,0 +1,20 @@
+>"+0#0000e05#ffffff0| |V|i|m| |:|d|e|f| |c|o|m@1|a|n|d| +0#0000000&@56
+@75
+@75
+|"+0#0000e05&| |l|i|s|t| +0#0000000&@68
+@75
+|d+0#af5f00255&|e|f| +0#0000000&@71
+|d+0#af5f00255&|e|f| +0#0000000&|F|o@1| @67
+|d+0#af5f00255&|e|f| +0#0000000&|/+0#af5f00255&|F+0#0000000&|o@1|.|*| @64
+@75
+|d+0#af5f00255&|e|f| +0#0000000&||| |e+0#af5f00255&|c|h|o| +0#0000000&|"+0#e000002&|F|o@1|"| +0#0000000&@58
+|d+0#af5f00255&|e|f| +0#0000000&|"+0#0000e05&| |c|o|m@1|e|n|t| +0#0000000&@61
+|d+0#af5f00255&|e|f| +0#0000000&|F|o@1| ||| |e+0#af5f00255&|c|h|o| +0#0000000&|"+0#e000002&|F|o@1|"| +0#0000000&@54
+|d+0#af5f00255&|e|f| +0#0000000&|F|o@1| |"+0#0000e05&| |c|o|m@1|e|n|t| +0#0000000&@57
+@75
+@75
+|"+0#0000e05&| |d|e|f|i|n|i|t|i|o|n| +0#0000000&@62
+@75
+|"+0#0000e05&| |e|m|p|t|y| |d|e|f|i|n|i|t|i|o|n| +0#0000000&@56
+|d+0#af5f00255&|e|f| +0#0000000&|F|o@1|(+0#e000e06&|)| +0#0000000&@65
+@57|1|,|1| @10|T|o|p|
diff --git a/runtime/syntax/testdir/dumps/vim_ex_def_01.dump b/runtime/syntax/testdir/dumps/vim_ex_def_01.dump
new file mode 100644
index 0000000000..c7b49de976
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/vim_ex_def_01.dump
@@ -0,0 +1,20 @@
+| +0&#ffffff0@74
+@75
+|"+0#0000e05&| |d|e|f|i|n|i|t|i|o|n| +0#0000000&@62
+@75
+|"+0#0000e05&| |e|m|p|t|y| |d|e|f|i|n|i|t|i|o|n| +0#0000000&@56
+>d+0#af5f00255&|e|f| +0#0000000&|F|o@1|(+0#e000e06&|)| +0#0000000&@65
+|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@68
+@75
+|#+0#0000e05&| |c|u|r|l|y|-|b|r|a|c|e| |n|a|m|e|s| +0#0000000&@55
+|d+0#af5f00255&|e|f| +0#0000000&|{|"|F|"|}|o@1|(+0#e000e06&|)| +0#0000000&@61
+|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@68
+@75
+|d+0#af5f00255&|e|f| +0#0000000&|F|{|"|o|"|}|o|(+0#e000e06&|)| +0#0000000&@61
+|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@68
+@75
+|d+0#af5f00255&|e|f| +0#0000000&|F|o|{|"|o|"|}|(+0#e000e06&|)| +0#0000000&@61
+|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@68
+@75
+|d+0#af5f00255&|e|f| +0#0000000&|{|"|F|"|}|o|{|"|o|"|}|(+0#e000e06&|)| +0#0000000&@57
+@57|1|9|,|1| @9|1|2|%|
diff --git a/runtime/syntax/testdir/dumps/vim_ex_def_02.dump b/runtime/syntax/testdir/dumps/vim_ex_def_02.dump
new file mode 100644
index 0000000000..7ebe3c666b
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/vim_ex_def_02.dump
@@ -0,0 +1,20 @@
+|d+0#af5f00255#ffffff0|e|f| +0#0000000&|{|"|F|"|}|o|{|"|o|"|}|(+0#e000e06&|)| +0#0000000&@57
+|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@68
+@75
+|d+0#af5f00255&|e|f| +0#0000000&|{|"|F|"|}|{|"|o|"|}|{|"|o|"|}|(+0#e000e06&|)| +0#0000000&@53
+|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@68
+> @74
+|d+0#af5f00255&|e|f| +0#0000000&|F|o@1|(+0#e000e06&|)|:+0#0000000&| |n+0#00e0003&|u|m|b|e|r| +0#0000000&@57
+@2|r+0#af5f00255&|e|t|u|r|n| +0#0000000&|4+0#e000002&|2| +0#0000000&@63
+|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@68
+@75
+|#+0#0000e05&| |t|r|a|i|l|i|n|g| |w|h|i|t|e|s|p|a|c|e| +0#0000000&@53
+|d+0#af5f00255&|e|f| +0#0000000&|F|o@1|(+0#e000e06&|)|:+0#0000000&| |n+0#00e0003&|u|m|b|e|r| +0#0000000&@57
+@2|r+0#af5f00255&|e|t|u|r|n| +0#0000000&|4+0#e000002&|2| +0#0000000&@63
+|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@68
+@75
+|d+0#af5f00255&|e|f| +0#0000000&|F|o@1|(+0#e000e06&|)| +0#0000000&|#+0#0000e05&| |c|o|m@1|e|n|t| +0#0000000&@55
+|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@68
+@75
+|d+0#af5f00255&|e|f| +0#0000000&|F|o@1|(+0#e000e06&|)|:+0#0000000&| |n+0#00e0003&|u|m|b|e|r| +0#0000000&|#+0#0000e05&| |c|o|m@1|e|n|t| +0#0000000&@47
+@57|3|7|,|0|-|1| @7|2|9|%|
diff --git a/runtime/syntax/testdir/dumps/vim_ex_def_03.dump b/runtime/syntax/testdir/dumps/vim_ex_def_03.dump
new file mode 100644
index 0000000000..50fed4124f
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/vim_ex_def_03.dump
@@ -0,0 +1,20 @@
+|d+0#af5f00255#ffffff0|e|f| +0#0000000&|F|o@1|(+0#e000e06&|)|:+0#0000000&| |n+0#00e0003&|u|m|b|e|r| +0#0000000&|#+0#0000e05&| |c|o|m@1|e|n|t| +0#0000000&@47
+@2|r+0#af5f00255&|e|t|u|r|n| +0#0000000&|4+0#e000002&|2| +0#0000000&@63
+|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@68
+@75
+|d+0#af5f00255&|e|f|!| +0#0000000&|F|o@1|(+0#e000e06&|)|:+0#0000000&| |n+0#00e0003&|u|m|b|e|r| +0#0000000&@56
+@2>r+0#af5f00255&|e|t|u|r|n| +0#0000000&|4+0#e000002&|2| +0#0000000&@63
+|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@68
+@75
+|d+0#af5f00255&|e|f| +0#0000000&|g+0#e000e06&|:|F+0#0000000&|o@1|(+0#e000e06&|)|:+0#0000000&| |n+0#00e0003&|u|m|b|e|r| +0#0000000&@55
+@2|r+0#af5f00255&|e|t|u|r|n| +0#0000000&|4+0#e000002&|2| +0#0000000&@63
+|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@68
+@75
+|d+0#af5f00255&|e|f| +0#0000000&|s+0#e000e06&|:|F+0#0000000&|o@1|(+0#e000e06&|)|:+0#0000000&| |n+0#00e0003&|u|m|b|e|r| +0#0000000&@55
+@2|r+0#af5f00255&|e|t|u|r|n| +0#0000000&|4+0#e000002&|2| +0#0000000&@63
+|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@68
+@75
+|d+0#af5f00255&|e|f| +0#0000000&|<+0#e000e06&|S|I|D|>|F+0#0000000&|o@1|(+0#e000e06&|)|:+0#0000000&| |n+0#00e0003&|u|m|b|e|r| +0#0000000&@52
+@2|r+0#af5f00255&|e|t|u|r|n| +0#0000000&|4+0#e000002&|2| +0#0000000&@63
+|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@68
+@57|5@1|,|3| @9|4|6|%|
diff --git a/runtime/syntax/testdir/dumps/vim_ex_def_04.dump b/runtime/syntax/testdir/dumps/vim_ex_def_04.dump
new file mode 100644
index 0000000000..64141b7ca9
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/vim_ex_def_04.dump
@@ -0,0 +1,20 @@
+|e+0#af5f00255#ffffff0|n|d@1|e|f| +0#0000000&@68
+@75
+|d+0#af5f00255&|e|f| +0#0000000&|f|o@1|#|b|a|r|#|F|o@1|(+0#e000e06&|)|:+0#0000000&| |n+0#00e0003&|u|m|b|e|r| +0#0000000&@49
+@2|r+0#af5f00255&|e|t|u|r|n| +0#0000000&|4+0#e000002&|2| +0#0000000&@63
+|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@68
+> @74
+|"+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
+|d+0#af5f00255&|e|f| +0#0000000&|s+0#e000e06&|:|l+0#0000000&|s|(+0#e000e06&|)| +0#0000000&@64
+|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@68
+@75
+@75
+|"+0#0000e05&| |r|e|t|u|r|n| |t|y|p|e|s| +0#0000000&@60
+@75
+|d+0#af5f00255&|e|f| +0#0000000&|F|o@1|(+0#e000e06&|)|:+0#0000000&| |v+0#00e0003&|o|i|d| +0#0000000&@59
+|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@68
+@75
+|d+0#af5f00255&|e|f| +0#0000000&|F|o@1|(+0#e000e06&|)|:+0#0000000&| |v+0#00e0003&|o|i|d| +0#0000000&|#+0#0000e05&| |c|o|m@1|e|n|t| +0#0000000&@49
+|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@68
+@75
+@57|7|3|,|0|-|1| @7|6|3|%|
diff --git a/runtime/syntax/testdir/dumps/vim_ex_def_05.dump b/runtime/syntax/testdir/dumps/vim_ex_def_05.dump
new file mode 100644
index 0000000000..9fc0cfa348
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/vim_ex_def_05.dump
@@ -0,0 +1,20 @@
+|d+0#af5f00255#ffffff0|e|f| +0#0000000&|F|o@1|(+0#e000e06&|)|:+0#0000000&| |l+0#00e0003&|i|s|t|<|d|i|c|t|<|n|u|m|b|e|r|>@1| +0#0000000&@45
+|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@68
+@75
+|d+0#af5f00255&|e|f| +0#0000000&|F|o@1|(+0#e000e06&|)|:+0#0000000&| |f+0#00e0003&|u|n|c|(|d|i|c|t|<|l|i|s|t|<|n|u|m|b|e|r|>@1|,+0#0000000&| |f+0#00e0003&|u|n|c|,+0#0000000&| |b+0#00e0003&|o@1|l|,+0#0000000&| |f+0#00e0003&|u|n|c|(|n|u|m|b|e|r|,+0#0000000&| |l+0#00e0003&|i|s|t|<|n|u|m|b|e|r|>|)@1
+|:+0#0000000&| |b+0#00e0003&|o@1|l| +0#0000000&@68
+>e+0#af5f00255&|n|d@1|e|f| +0#0000000&@68
+@75
+@75
+|"+0#0000e05&| |:|e|n|d@1|e|f| |t|r|a|i|l|i|n|g| +0#0000000&@56
+@75
+|d+0#af5f00255&|e|f| +0#0000000&|F|o@1|(+0#e000e06&|)| +0#0000000&@65
+| +0#0000e05&@1|#| |t|r|a|i|l|i|n|g| |w|h|i|t|e|s|p|a|c|e| +0#0000000&@51
+|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@68
+@75
+|d+0#af5f00255&|e|f| +0#0000000&|F|o@1|(+0#e000e06&|)| +0#0000000&@65
+|e+0#af5f00255&|n|d@1|e|f| +0#0000000&||| |e+0#af5f00255&|c|h|o| +0#0000000&|"+0#e000002&|F|o@1|"| +0#0000000&@55
+@75
+|d+0#af5f00255&|e|f| +0#0000000&|F|o@1|(+0#e000e06&|)| +0#0000000&@65
+|e+0#af5f00255&|n|d@1|e|f| +0#0000000&|"+0#0000e05&| |c|o|m@1|e|n|t| +0#0000000&@58
+@57|9|1|,|1| @9|8|0|%|
diff --git a/runtime/syntax/testdir/dumps/vim_ex_def_06.dump b/runtime/syntax/testdir/dumps/vim_ex_def_06.dump
new file mode 100644
index 0000000000..f07302656a
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/vim_ex_def_06.dump
@@ -0,0 +1,20 @@
+|e+0#af5f00255#ffffff0|n|d@1|e|f| +0#0000000&|"+0#0000e05&| |c|o|m@1|e|n|t| +0#0000000&@58
+@75
+@75
+|"+0#0000e05&| |p|a|r|a|m|e|t|e|r|s| +0#0000000&@62
+@75
+>d+0#af5f00255&|e|f| +0#0000000&|F|o@1|(+0#e000e06&|x+0#00e0e07&|:+0#0000000&| |b+0#00e0003&|o@1|l|,+0#0000000&| |y+0#00e0e07&| +0#0000000&|=+0#af5f00255&| +0#0000000&|4+0#e000002&|2|,+0#0000000&| |z+0#00e0e07&|:+0#0000000&| |s+0#00e0003&|t|r|i|n|g| +0#0000000&|=+0#af5f00255&| +0#0000000&|"+0#e000002&|z|e|d|"|)+0#e000e06&| +0#0000000&@31
+|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@68
+@75
+|d+0#af5f00255&|e|f| +0#0000000&|F|o@1|(+0#e000e06&| +0#0000000&@66
+@4|x+0#00e0e07&|:+0#0000000&| |b+0#00e0003&|o@1|l|,+0#0000000&| @62
+@4|y+0#00e0e07&| +0#0000000&|=+0#af5f00255&| +0#0000000&|4+0#e000002&|2|,+0#0000000&| @63
+@4|z+0#00e0e07&|:+0#0000000&| |s+0#00e0003&|t|r|i|n|g| +0#0000000&|=+0#af5f00255&| +0#0000000&|"+0#e000002&|z|e|d|"|)+0#e000e06&| +0#0000000&@52
+|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@68
+@75
+@75
+|"+0#0000e05&| |c|o|m@1|e|n|t|s| +0#0000000&@64
+@75
+|d+0#af5f00255&|e|f| +0#0000000&|F|o@1|(+0#e000e06&|)| +0#0000000&@65
+| +0#0000e05&@1|#| |V|i|m|9|-|s|c|r|i|p|t| |c|o|m@1|e|n|t| +0#0000000&@51
+@57|1|0|9|,|1| @8|9|7|%|
diff --git a/runtime/syntax/testdir/dumps/vim_ex_def_99.dump b/runtime/syntax/testdir/dumps/vim_ex_def_99.dump
new file mode 100644
index 0000000000..2eca72a57b
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/vim_ex_def_99.dump
@@ -0,0 +1,20 @@
+|"+0#0000e05#ffffff0| |p|a|r|a|m|e|t|e|r|s| +0#0000000&@62
+@75
+|d+0#af5f00255&|e|f| +0#0000000&|F|o@1|(+0#e000e06&|x+0#00e0e07&|:+0#0000000&| |b+0#00e0003&|o@1|l|,+0#0000000&| |y+0#00e0e07&| +0#0000000&|=+0#af5f00255&| +0#0000000&|4+0#e000002&|2|,+0#0000000&| |z+0#00e0e07&|:+0#0000000&| |s+0#00e0003&|t|r|i|n|g| +0#0000000&|=+0#af5f00255&| +0#0000000&|"+0#e000002&|z|e|d|"|)+0#e000e06&| +0#0000000&@31
+|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@68
+@75
+|d+0#af5f00255&|e|f| +0#0000000&|F|o@1|(+0#e000e06&| +0#0000000&@66
+@4|x+0#00e0e07&|:+0#0000000&| |b+0#00e0003&|o@1|l|,+0#0000000&| @62
+@4|y+0#00e0e07&| +0#0000000&|=+0#af5f00255&| +0#0000000&|4+0#e000002&|2|,+0#0000000&| @63
+@4|z+0#00e0e07&|:+0#0000000&| |s+0#00e0003&|t|r|i|n|g| +0#0000000&|=+0#af5f00255&| +0#0000000&|"+0#e000002&|z|e|d|"|)+0#e000e06&| +0#0000000&@52
+|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@68
+@75
+@75
+|"+0#0000e05&| |c|o|m@1|e|n|t|s| +0#0000000&@64
+@75
+|d+0#af5f00255&|e|f| +0#0000000&|F|o@1|(+0#e000e06&|)| +0#0000000&@65
+| +0#0000e05&@1|#| |V|i|m|9|-|s|c|r|i|p|t| |c|o|m@1|e|n|t| +0#0000000&@51
+@2|"+0#e000002&|u|s|e|l|e|s@1| |s|t|r|i|n|g|"| +0#0000000&@56
+|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@68
+> @74
+@57|1|2|5|,|0|-|1| @6|B|o|t|
diff --git a/runtime/syntax/testdir/dumps/vim_ex_def_fold_00.dump b/runtime/syntax/testdir/dumps/vim_ex_def_fold_00.dump
new file mode 100644
index 0000000000..78659e7e6e
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/vim_ex_def_fold_00.dump
@@ -0,0 +1,20 @@
+>"+0#0000e05#ffffff0| |V|i|m| |:|d|e|f| |c|o|m@1|a|n|d| +0#0000000&@56
+|"+0#0000e05&| |V|I|M|_|T|E|S|T|_|S|E|T|U|P| |l|e|t| |g|:|v|i|m|s|y|n|_|f|o|l|d|i|n|g| |=| |"+0#e000002&|f|"| +0#0000e05&||| |s|e|t| |f|d|m|=|s|y|n|t|a|x| +0#0000000&@14
+@75
+@75
+|"+0#0000e05&| |l|i|s|t| +0#0000000&@68
+@75
+|d+0#af5f00255&|e|f| +0#0000000&@71
+|d+0#af5f00255&|e|f| +0#0000000&|F|o@1| @67
+|d+0#af5f00255&|e|f| +0#0000000&|/+0#af5f00255&|F+0#0000000&|o@1|.|*| @64
+@75
+|d+0#af5f00255&|e|f| +0#0000000&||| |e+0#af5f00255&|c|h|o| +0#0000000&|"+0#e000002&|F|o@1|"| +0#0000000&@58
+|d+0#af5f00255&|e|f| +0#0000000&|"+0#0000e05&| |c|o|m@1|e|n|t| +0#0000000&@61
+|d+0#af5f00255&|e|f| +0#0000000&|F|o@1| ||| |e+0#af5f00255&|c|h|o| +0#0000000&|"+0#e000002&|F|o@1|"| +0#0000000&@54
+|d+0#af5f00255&|e|f| +0#0000000&|F|o@1| |"+0#0000e05&| |c|o|m@1|e|n|t| +0#0000000&@57
+@75
+@75
+|"+0#0000e05&| |d|e|f|i|n|i|t|i|o|n| +0#0000000&@62
+@75
+|"+0#0000e05&| |e|m|p|t|y| |d|e|f|i|n|i|t|i|o|n| +0#0000000&@56
+@57|1|,|1| @10|T|o|p|
diff --git a/runtime/syntax/testdir/dumps/vim_ex_def_fold_01.dump b/runtime/syntax/testdir/dumps/vim_ex_def_fold_01.dump
new file mode 100644
index 0000000000..d1803d5e37
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/vim_ex_def_fold_01.dump
@@ -0,0 +1,20 @@
+|d+0#af5f00255#ffffff0|e|f| +0#0000000&|F|o@1| |"+0#0000e05&| |c|o|m@1|e|n|t| +0#0000000&@57
+@75
+@75
+|"+0#0000e05&| |d|e|f|i|n|i|t|i|o|n| +0#0000000&@62
+@75
+>"+0#0000e05&| |e|m|p|t|y| |d|e|f|i|n|i|t|i|o|n| +0#0000000&@56
+|++0#0000e05#a8a8a8255|-@1| @1|2| |l|i|n|e|s|:| |d|e|f| |F|o@1|(|)|-@51
+| +0#0000000#ffffff0@74
+|#+0#0000e05&| |c|u|r|l|y|-|b|r|a|c|e| |n|a|m|e|s| +0#0000000&@55
+|++0#0000e05#a8a8a8255|-@1| @1|2| |l|i|n|e|s|:| |d|e|f| |{|"|F|"|}|o@1|(|)|-@47
+| +0#0000000#ffffff0@74
+|++0#0000e05#a8a8a8255|-@1| @1|2| |l|i|n|e|s|:| |d|e|f| |F|{|"|o|"|}|o|(|)|-@47
+| +0#0000000#ffffff0@74
+|++0#0000e05#a8a8a8255|-@1| @1|2| |l|i|n|e|s|:| |d|e|f| |F|o|{|"|o|"|}|(|)|-@47
+| +0#0000000#ffffff0@74
+|++0#0000e05#a8a8a8255|-@1| @1|2| |l|i|n|e|s|:| |d|e|f| |{|"|F|"|}|o|{|"|o|"|}|(|)|-@43
+| +0#0000000#ffffff0@74
+|++0#0000e05#a8a8a8255|-@1| @1|2| |l|i|n|e|s|:| |d|e|f| |{|"|F|"|}|{|"|o|"|}|{|"|o|"|}|(|)|-@39
+| +0#0000000#ffffff0@74
+@57|1|9|,|1| @9|1|2|%|
diff --git a/runtime/syntax/testdir/dumps/vim_ex_def_fold_02.dump b/runtime/syntax/testdir/dumps/vim_ex_def_fold_02.dump
new file mode 100644
index 0000000000..d9668cd59f
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/vim_ex_def_fold_02.dump
@@ -0,0 +1,20 @@
+| +0&#ffffff0@74
+|++0#0000e05#a8a8a8255|-@1| @1|2| |l|i|n|e|s|:| |d|e|f| |F|o|{|"|o|"|}|(|)|-@47
+| +0#0000000#ffffff0@74
+|++0#0000e05#a8a8a8255|-@1| @1|2| |l|i|n|e|s|:| |d|e|f| |{|"|F|"|}|o|{|"|o|"|}|(|)|-@43
+| +0#0000000#ffffff0@74
+>++0#0000e05#a8a8a8255|-@1| @1|2| |l|i|n|e|s|:| |d|e|f| |{|"|F|"|}|{|"|o|"|}|{|"|o|"|}|(|)|-@39
+| +0#0000000#ffffff0@74
+|++0#0000e05#a8a8a8255|-@1| @1|3| |l|i|n|e|s|:| |d|e|f| |F|o@1|(|)|:| |n|u|m|b|e|r|-@43
+| +0#0000000#ffffff0@74
+|#+0#0000e05&| |t|r|a|i|l|i|n|g| |w|h|i|t|e|s|p|a|c|e| +0#0000000&@53
+|++0#0000e05#a8a8a8255|-@1| @1|3| |l|i|n|e|s|:| |d|e|f|