@@ -660,40 +660,43 @@ if !exists("b:is_posix")
660660 syn keyword shFunctionKey function skipwhite skipnl nextgroup =shDoError,shIfError,shFunctionTwo,shFunctionFour,shFunctionCmdTwo
661661endif
662662
663+ ShFoldFunctions syn region shFunctionExpr matchgroup= shFunctionExprRegion start = " {" end = " }" contains= @s hFunctionList contained skipwhite skipnl nextgroup= shQuickComment
664+ ShFoldFunctions syn region shFunctionSubSh matchgroup= shFunctionSubShRegion start = " (" end = " )" contains= @s hFunctionList contained skipwhite skipnl nextgroup= shQuickComment
665+
663666if exists (" b:is_bash" )
664667 syn keyword shFunctionKey coproc
665668 syn match shFunctionCmdOne " ^\s *\z s\% (\<\k\+\| [^()<>|&$;\t ]\+\)\+\s *()\z e\_ s*\% (\% (for\| case\| select\| if\| while\| until\)\>\|\[\[\s\| ((\) " skipwhite skipnl nextgroup =@shFunctionCmds
666669 syn match shFunctionCmdTwo " \% (\<\k\+\>\| [^()<>|&$;\t ]\+\)\+\z e\s *\% (()\z e\)\=\_ s*\% (\<\% (for\| case\| select\| if\| while\| until\)\>\|\[\[\s\| ((\) " contained skipwhite skipnl nextgroup =@shFunctionCmds
667- ShFoldFunctions syn region shFunctionOne matchgroup = shFunction start = " ^\s *\z s\% (\<\k\+\|[^()<> |&$;\t ]\+\)\+\s *()\_ s*{" end = " } " contains = @s hFunctionList skipwhite skipnl nextgroup= shQuickComment
668- ShFoldFunctions syn region shFunctionTwo matchgroup = shFunction start = " \% (\<\k\+\|[^()<> |&$;\t ]\+\)\+\s *\% (()\)\=\_ s*{" end = " } " contains = shFunctionKey, @s hFunctionList contained skipwhite skipnl nextgroup= shQuickComment
669- ShFoldFunctions syn region shFunctionThree matchgroup = shFunction start = " ^\s *\z s\% (\<\k\+\|[^()<> |&$;\t ]\+\)\+\s *()\_ s*((\@ !" end = " ) " contains = @s hFunctionList skipwhite skipnl nextgroup= shQuickComment
670- ShFoldFunctions syn region shFunctionFour matchgroup = shFunction start = " \% (\<\k\+\|[^()<> |&$;\t ]\+\)\+\s *\% (\% (()\)\=\)\@ >\_ s*((\@ !" end = " ) " contains = shFunctionKey, @s hFunctionList contained skipwhite skipnl nextgroup= shQuickComment
670+ syn match shFunctionOne " ^\s *\z s\% (\<\k\+\| [^()<>|&$;\t ]\+\)\+\s *()\z e \ _ s*{" skipwhite skipnl nextgroup =shFunctionExpr
671+ syn match shFunctionTwo " \% (\<\k\+\| [^()<>|&$;\t ]\+\)\+\z e \ s *\% (()\z e \ )\=\_ s*{" contained skipwhite skipnl nextgroup =shFunctionExpr
672+ syn match shFunctionThree " ^\s *\z s\% (\<\k\+\| [^()<>|&$;\t ]\+\)\+\s *()\z e \ _ s*((\@ !" skipwhite skipnl nextgroup =shFunctionSubSh
673+ syn match shFunctionFour " \% (\<\k\+\| [^()<>|&$;\t ]\+\)\+\z e \ s *\% (\% (()\z e \ )\=\)\@ >\_ s*((\@ !" contained skipwhite skipnl nextgroup =shFunctionSubSh
671674elseif exists (" b:is_ksh88" )
672675 " AT&T ksh88
673676 syn match shFunctionCmdOne " ^\s *\z s\h\w *\s *()\z e\_ s*\% (\% (for\| case\| select\| if\| while\| until\)\>\|\[\[\s\| ((\) " skipwhite skipnl nextgroup =@shFunctionCmds
674- ShFoldFunctions syn region shFunctionOne matchgroup = shFunction start = " ^\s *\z s\h\w *\s *()\_ s*{" end = " } " contains = @s hFunctionList skipwhite skipnl nextgroup= shQuickComment
675- ShFoldFunctions syn region shFunctionTwo matchgroup = shFunction start = " \<\h\w *\>\_ s*{" end = " } " contains = shFunctionKey, @s hFunctionList contained skipwhite skipnl nextgroup= shQuickComment
676- ShFoldFunctions syn region shFunctionThree matchgroup = shFunction start = " ^\s *\z s\h\w *\s *()\_ s*((\@ !" end = " ) " contains = @s hFunctionList skipwhite skipnl nextgroup= shQuickComment
677+ syn match shFunctionOne " ^\s *\z s\h\w *\s *()\z e \ _ s*{" skipwhite skipnl nextgroup =shFunctionExpr
678+ syn match shFunctionTwo " \<\h\w *\>\z e \ _ s*{" contained skipwhite skipnl nextgroup =shFunctionExpr
679+ syn match shFunctionThree " ^\s *\z s\h\w *\s *()\z e \ _ s*((\@ !" skipwhite skipnl nextgroup =shFunctionSubSh
677680elseif exists (" b:is_mksh" )
678681 " MirBSD ksh is the wild west of absurd and abstruse function names...
679682 syn match shFunctionCmdOne " ^\s *\z s[-A-Za-z_@!+.%,0-9:]*[-A-Za-z_.%,0-9:]\s *()\z e\_ s*\% (\% (for\| case\| select\| if\| while\| until\)\>\|\[\[\s\| ((\) " skipwhite skipnl nextgroup =@shFunctionCmds
680- ShFoldFunctions syn region shFunctionOne matchgroup = shFunction start = " ^\s *\z s[-A-Za-z_@!+.%,0-9:]*[-A-Za-z_.%,0-9:]\s *()\_ s*{" end = " } " contains = @s hFunctionList skipwhite skipnl nextgroup= shQuickComment
681- ShFoldFunctions syn region shFunctionTwo matchgroup = shFunction start = " \% ([@!+.%,:-]\+\|\<\w\+\) *[-A-Za-z_.%,0-9:]\s *\% (()\)\=\_ s*{" end = " } " contains = shFunctionKey, @s hFunctionList contained skipwhite skipnl nextgroup= shQuickComment
682- ShFoldFunctions syn region shFunctionThree matchgroup = shFunction start = " ^\s *\z s[-A-Za-z_@!+.%,0-9:]*[-A-Za-z_.%,0-9:]\s *()\_ s*((\@ !" end = " ) " contains = @s hFunctionList skipwhite skipnl nextgroup= shQuickComment
683+ syn match shFunctionOne " ^\s *\z s[-A-Za-z_@!+.%,0-9:]*[-A-Za-z_.%,0-9:]\s *()\z e \ _ s*{" skipwhite skipnl nextgroup =shFunctionExpr
684+ syn match shFunctionTwo " \% ([@!+.%,:-]\+\|\<\w\+\) *[-A-Za-z_.%,0-9:]\z e \ s *\% (()\z e \ )\=\_ s*{" contained skipwhite skipnl nextgroup =shFunctionExpr
685+ syn match shFunctionThree " ^\s *\z s[-A-Za-z_@!+.%,0-9:]*[-A-Za-z_.%,0-9:]\s *()\z e \ _ s*((\@ !" skipwhite skipnl nextgroup =shFunctionSubSh
683686elseif exists (" b:is_kornshell" )
684687 " ksh93
685688 syn match shFunctionCmdOne " ^\s *\z s[A-Za-z_.][A-Za-z_.0-9]*\s *()\z e\_ s*\% (\% (for\| case\| select\| if\| while\| until\)\>\|\[\[\s\| ((\) " skipwhite skipnl nextgroup =@shFunctionCmds
686- ShFoldFunctions syn region shFunctionOne matchgroup = shFunction start = " ^\s *\z s[A-Za-z_.][A-Za-z_.0-9]*\s *()\_ s*{" end = " } " contains = @s hFunctionList skipwhite skipnl nextgroup= shQuickComment
687- ShFoldFunctions syn region shFunctionTwo matchgroup = shFunction start = " \% (\.\|\<\h\+\) [A-Za-z_.0-9]*\_ s*{" end = " } " contains = shFunctionKey, @s hFunctionList contained skipwhite skipnl nextgroup= shQuickComment
688- ShFoldFunctions syn region shFunctionThree matchgroup = shFunction start = " ^\s *\z s[A-Za-z_.][A-Za-z_.0-9]*\s *()\_ s*((\@ !" end = " ) " contains = @s hFunctionList skipwhite skipnl nextgroup= shQuickComment
689- ShFoldFunctions syn region shNamespaceOne matchgroup = shFunction start = " \<\h\w *\>\_ s*{" end = " } " contains = shFunctionKey, @s hFunctionList contained skipwhite skipnl nextgroup= shQuickComment
689+ syn match shFunctionOne " ^\s *\z s[A-Za-z_.][A-Za-z_.0-9]*\s *()\z e \ _ s*{" skipwhite skipnl nextgroup =shFunctionExpr
690+ syn match shFunctionTwo " \% (\.\|\<\h\+\) [A-Za-z_.0-9]*\z e \ _ s*{" contained skipwhite skipnl nextgroup =shFunctionExpr
691+ syn match shFunctionThree " ^\s *\z s[A-Za-z_.][A-Za-z_.0-9]*\s *()\z e \ _ s*((\@ !" skipwhite skipnl nextgroup =shFunctionSubSh
692+ syn match shNamespaceOne " \<\h\w *\>\z e \ _ s*{" contained skipwhite skipnl nextgroup =shFunctionExpr
690693else
691694 syn match shFunctionCmdOne " ^\s *\z s\h\w *\s *()\z e\_ s*\% (for\| case\| if\| while\| until\)\> " skipwhite skipnl nextgroup =@shFunctionCmds
692695 syn match shFunctionCmdTwo " \<\h\w *\s *()\z e\_ s*\% (for\| case\| if\| while\| until\)\> " contained skipwhite skipnl nextgroup =@shFunctionCmds
693- ShFoldFunctions syn region shFunctionOne matchgroup = shFunction start = " ^\s *\z s\h\w *\s *()\_ s*{" end = " } " contains = @s hFunctionList skipwhite skipnl nextgroup= shQuickComment
694- ShFoldFunctions syn region shFunctionTwo matchgroup = shFunction start = " \<\h\w *\>\s *()\_ s*{" end = " } " contains = shFunctionKey, @s hFunctionList contained skipwhite skipnl nextgroup= shQuickComment
695- ShFoldFunctions syn region shFunctionThree matchgroup = shFunction start = " ^\s *\z s\h\w *\s *()\_ s*(" end = " ) " contains = @s hFunctionList skipwhite skipnl nextgroup= shQuickComment
696- ShFoldFunctions syn region shFunctionFour matchgroup = shFunction start = " \<\h\w *\>\s *()\_ s*(" end = " ) " contains = shFunctionKey, @s hFunctionList contained skipwhite skipnl nextgroup= shQuickComment
696+ syn match shFunctionOne " ^\s *\z s\h\w *\s *()\z e \ _ s*{" skipwhite skipnl nextgroup =shFunctionExpr
697+ syn match shFunctionTwo " \<\h\w *\>\s *()\z e \ _ s*{" contained skipwhite skipnl nextgroup =shFunctionExpr
698+ syn match shFunctionThree " ^\s *\z s\h\w *\s *()\z e \ _ s*(" skipwhite skipnl nextgroup =shFunctionSubSh
699+ syn match shFunctionFour " \<\h\w *\>\s *()\z e \ _ s*(" contained skipwhite skipnl nextgroup =shFunctionSubSh
697700endif
698701
699702if ! exists (" g:sh_no_error" )
@@ -902,9 +905,6 @@ if !exists("skip_sh_syntax_inits")
902905 hi def link shEchoDelim shOperator
903906 hi def link shEchoQuote shString
904907 hi def link shForPP shLoop
905- hi def link shFunction Function
906- hi def link shFunctionCmdOne shFunction
907- hi def link shFunctionCmdTwo shFunction
908908 hi def link shEmbeddedEcho shString
909909 hi def link shEscape shCommandSub
910910 hi def link shExDoubleQuote shDoubleQuote
@@ -982,8 +982,16 @@ if !exists("skip_sh_syntax_inits")
982982 hi def link shConditional Conditional
983983 hi def link shCtrlSeq Special
984984 hi def link shExprRegion Delimiter
985- hi def link shFunctionKey Function
986- hi def link shFunctionName Function
985+ hi def link shFunctionKey Keyword
986+ hi def link shFunctionOne Function
987+ hi def link shFunctionTwo shFunctionOne
988+ hi def link shFunctionThree shFunctionOne
989+ hi def link shFunctionFour shFunctionOne
990+ hi def link shFunctionCmdOne shFunctionOne
991+ hi def link shFunctionCmdTwo shFunctionOne
992+ hi def link shFunctionExprRegion shExprRegion
993+ hi def link shFunctionSubShRegion shSubShRegion
994+ hi def link shNamespaceOne Function
987995 hi def link shNumber Number
988996 hi def link shOperator Operator
989997 hi def link shRepeat Repeat
0 commit comments