" MNV syntax file
" Language:	   MNV script
" Maintainer:	   Hirohito Higashi <h.east.727 ATMARK gmail.com>
"	   Doug Kearns <dougkearns@gmail.com>
" Last Change:	   2026 Feb 20
" Former Maintainer: Charles E. Campbell

" DO NOT CHANGE DIRECTLY.
" THIS FILE PARTLY GENERATED BY gen_syntax_mnv.mnv.
" (Search string "GEN_SYN_MNV:" in this file)

" Quit when a syntax file was already loaded {{{1
if exists("b:current_syntax")
  finish
endif
let s:keepcpo= &cpo
set cpo&mnv

" Feature testing {{{1

" NOTE: mnvsyn_force_mnv9 for internal use only
let s:mnv9script = get(b:, "mnvsyn_force_mnv9", v:false) || "\n" .. getline(1, 32)->join("\n") =~# '\n\s*mnv9\%[script]\>'

function s:has(feature)
  return has(a:feature) || index(get(g:, "mnvsyn_mnv_features", []), a:feature) != -1
endfunction

" Automatically generated keyword lists: {{{1

" mnvTodo: contains common special-notices for comments {{{2
" Use the mnvCommentGroup cluster to add your own.
syn keyword mnvTodo contained	COMBAK	FIXME	TODO	XXX
syn cluster mnvCommentGroup	contains=mnvTodo,@Spell

" regular mnv commands {{{2
" GEN_SYN_MNV: mnvCommand normal, START_STR='syn keyword mnvCommand contained', END_STR='nextgroup=mnvBang'

" Lower priority :syn-match to allow for :command/function() distinction
" :chdir is handled specially elsewhere
syn match mnvCommand "\<co\%[py]\>"     nextgroup=mnvBang
syn match mnvCommand "\<d\%[elete]\>"   nextgroup=mnvBang
syn match mnvCommand "\<j\%[oin]\>"     nextgroup=mnvBang
syn match mnvCommand "\<sp\%[lit]\>"    nextgroup=mnvBang
syn match mnvCommand "\<sw\%[apname]\>" nextgroup=mnvBang

" GEN_SYN_MNV: mnvCommand modifier, START_STR='syn keyword mnvCommandModifier', END_STR='skipwhite nextgroup=mnvCommandModifierBang,@mnvCmdList'
" :filter is handled specially elsewhere
syn match	mnvCommandModifierBang	contained	"\a\@1<=!"	skipwhite nextgroup=@mnvCmdList

" Lower priority :syn-match to allow for :command/function() distinction
syn match mnvCommand "\<bro\%[wse]\>"  skipwhite nextgroup=mnvCommandModifierBang,@mnvCmdList
syn match mnvCommand "\<conf\%[irm]\>" skipwhite nextgroup=mnvCommandModifierBang,@mnvCmdList

" Lower priority for _new_ to distinguish constructors from the command.
syn match   mnvCommand contained	"\<new\>(\@!"
syn match   mnvCommand contained	"\<z[-+^.=]\=\>"
syn keyword mnvStdPlugin contained	Arguments Asm Break Cfilter Clear Continue DiffOrig Evaluate Finish Gdb Lfilter Man Over Program Run S Source Step Stop Termdebug TermdebugCommand TOhtml Until Winbar XMLent XMLns

" mnvOptions are caught only when contained in a mnvSet {{{2
" GEN_SYN_MNV: mnvOption normal, START_STR='syn keyword mnvOption contained', END_STR='skipwhite nextgroup=mnvSetEqual,mnvSetMod'

" mnvOptions: These are the turn-off setting variants {{{2
" GEN_SYN_MNV: mnvOption turn-off, START_STR='syn keyword mnvOption contained', END_STR=''

" mnvOptions: These are the invertible variants {{{2
" GEN_SYN_MNV: mnvOption invertible, START_STR='syn keyword mnvOption contained', END_STR=''
" termcap codes (which can also be set) {{{2
" GEN_SYN_MNV: mnvOption term output code, START_STR='syn keyword mnvOption contained', END_STR='skipwhite nextgroup=mnvSetEqual,mnvSetMod'
" term key codes
syn keyword mnvOption contained	t_F1 t_F2 t_F3 t_F4 t_F5 t_F6 t_F7 t_F8 t_F9 t_k1 t_K1 t_k2 t_k3 t_K3 t_k4 t_K4 t_k5 t_K5 t_k6 t_K6 t_k7 t_K7 t_k8 t_K8 t_k9 t_K9 t_KA t_kb t_kB t_KB t_KC t_kd t_kD t_KD t_KE t_KF t_KG t_kh t_KH t_kI t_KI t_KJ t_KK t_kl t_KL t_kN t_kP t_kr t_ku
syn match   mnvOption contained	"t_%1"
syn match   mnvOption contained	"t_#2"
syn match   mnvOption contained	"t_#4"
syn match   mnvOption contained	"t_@7"
syn match   mnvOption contained	"t_*7"
syn match   mnvOption contained	"t_&8"
syn match   mnvOption contained	"t_%i"
syn match   mnvOption contained	"t_k;"

" mnvOptions: These are the variable names {{{2
" GEN_SYN_MNV: mnvOption normal variable,           START_STR='syn keyword mnvOptionVarName contained', END_STR=''
" GEN_SYN_MNV: mnvOption term output code variable, START_STR='syn keyword mnvOptionVarName contained', END_STR=''
syn keyword mnvOptionVarName contained	t_F1 t_F2 t_F3 t_F4 t_F5 t_F6 t_F7 t_F8 t_F9 t_k1 t_K1 t_k2 t_k3 t_K3 t_k4 t_K4 t_k5 t_K5 t_k6 t_K6 t_k7 t_K7 t_k8 t_K8 t_k9 t_K9 t_KA t_kb t_kB t_KB t_KC t_kd t_kD t_KD t_KE t_KF t_KG t_kh t_KH t_kI t_KI t_KJ t_KK t_kl t_KL t_kN t_kP t_kr t_ku
syn match   mnvOptionVarName contained	"t_%1"
syn match   mnvOptionVarName contained	"t_#2"
syn match   mnvOptionVarName contained	"t_#4"
syn match   mnvOptionVarName contained	"t_@7"
syn match   mnvOptionVarName contained	"t_*7"
syn match   mnvOptionVarName contained	"t_&8"
syn match   mnvOptionVarName contained	"t_%i"
syn match   mnvOptionVarName contained	"t_k;"

" unsupported settings: some were supported by vi but don't do anything in mnv {{{2
" GEN_SYN_MNV: Missing mnvOption, START_STR='syn keyword mnvErrSetting contained', END_STR=''

" AutoCmd Events {{{2
syn case ignore
" GEN_SYN_MNV: mnvAutoEvent, START_STR='syn keyword mnvAutoEvent contained', END_STR='skipwhite nextgroup=mnvAutoEventSep,@mnvAutocmdPattern'

syn keyword	mnvAutoEvent	contained	User	skipwhite nextgroup=mnvUserAutoEvent
syn match	mnvUserAutoEvent	contained	"\<\h\w*\>"	skipwhite nextgroup=mnvUserAutoEventSep,mnvAutocmdMod,mnvAutocmdBlock

" Highlight commonly used Groupnames {{{2
" GEN_SYN_MNV: mnvGroup, START_STR='syn keyword mnvGroup contained', END_STR=''

" Default highlighting groups {{{2
" GEN_SYN_MNV: mnvHLGroup, START_STR='syn keyword mnvHLGroup contained', END_STR=''
syn match mnvHLGroup contained "\<Conceal\>"
syn case match

" Function Names {{{2
" GEN_SYN_MNV: mnvFuncName, START_STR='syn keyword mnvFuncName contained', END_STR=''

" Predefined variable names {{{2
" GEN_SYN_MNV: mnvVarName, START_STR='syn keyword mnvMNVVarName contained', END_STR=''

"--- syntax here and above generated by runtime/syntax/generator/gen_syntax_mnv.mnv ---

" Special MNV Highlighting (not automatic) {{{1

" Neomnv keyword list additions {{{2

if s:has("nmnv")
  syn keyword mnvOptionVarName contained channel inccommand mousescroll pumblend redrawdebug scrollback shada shadafile statuscolumn termpastefilter termsync winbar winblend winhighlight
  syn keyword mnvFuncName      contained api_info buffer_exists buffer_name buffer_number chanclose chansend ctxget ctxpop ctxpush ctxset ctxsize dictwatcheradd dictwatcherdel file_readable highlight_exists highlightID jobclose jobpid jobresize jobsend jobstart jobstop jobwait last_buffer_nr menu_get msgpackdump msgpackparse reg_recorded rpcnotify rpcrequest rpcstart rpcstop serverstart serverstop sockconnect stdioopen stdpath termopen test_write_list_log wait
  syn match   mnvFuncName      contained "\<nmnv_\w\+\>"
  syn keyword mnvMNVVarName    contained lua msgpack_types relnum stderr termrequest virtnum
endif

" Set up commands for this syntax highlighting file {{{2

com! -nargs=* MNV9 execute <q-args> s:mnv9script ? "" : "contained"
com! -nargs=* MNVL execute <q-args> s:mnv9script ? "contained" : ""

if exists("g:mnvsyn_folding") && g:mnvsyn_folding =~# '[acefhiHlmpPrt]'
 if g:mnvsyn_folding =~# 'a'
  com! -nargs=* MNVFolda <args> fold
 else
  com! -nargs=* MNVFolda <args>
 endif
 if g:mnvsyn_folding =~# 'c'
  com! -nargs=* MNVFoldc <args> fold
 else
  com! -nargs=* MNVFoldc <args>
 endif
 if g:mnvsyn_folding =~# 'e'
  com! -nargs=* MNVFolde <args> fold
 else
  com! -nargs=* MNVFolde <args>
 endif
 if g:mnvsyn_folding =~# 'f'
  com! -nargs=* MNVFoldf <args> fold
 else
  com! -nargs=* MNVFoldf <args>
 endif
 if g:mnvsyn_folding =~# 'h'
  com! -nargs=* MNVFoldh <args> fold
 else
  com! -nargs=* MNVFoldh <args>
 endif
 if g:mnvsyn_folding =~# 'H'
  com! -nargs=* MNVFoldH <args> fold
 else
  com! -nargs=* MNVFoldH <args>
 endif
 if g:mnvsyn_folding =~# 'i'
  com! -nargs=* MNVFoldi <args> fold
 else
  com! -nargs=* MNVFoldi <args>
 endif
 if g:mnvsyn_folding =~# 'l'
  com! -nargs=* MNVFoldl <args> fold
 else
  com! -nargs=* MNVFoldl <args>
 endif
 if g:mnvsyn_folding =~# 'm'
  com! -nargs=* MNVFoldm <args> fold
 else
  com! -nargs=* MNVFoldm <args>
 endif
 if g:mnvsyn_folding =~# 'p'
  com! -nargs=* MNVFoldp <args> fold
 else
  com! -nargs=* MNVFoldp <args>
 endif
 if g:mnvsyn_folding =~# 'P'
  com! -nargs=* MNVFoldP <args> fold
 else
  com! -nargs=* MNVFoldP <args>
 endif
 if g:mnvsyn_folding =~# 'r'
  com! -nargs=* MNVFoldr <args> fold
 else
  com! -nargs=* MNVFoldr <args>
 endif
 if g:mnvsyn_folding =~# 't'
  com! -nargs=* MNVFoldt <args> fold
 else
  com! -nargs=* MNVFoldt <args>
 endif
else
 com! -nargs=*	MNVFolda	<args>
 com! -nargs=*	MNVFoldc	<args>
 com! -nargs=*	MNVFolde	<args>
 com! -nargs=*	MNVFoldf	<args>
 com! -nargs=*	MNVFoldi	<args>
 com! -nargs=*	MNVFoldh	<args>
 com! -nargs=*	MNVFoldH	<args>
 com! -nargs=*	MNVFoldl	<args>
 com! -nargs=*	MNVFoldm	<args>
 com! -nargs=*	MNVFoldp	<args>
 com! -nargs=*	MNVFoldP	<args>
 com! -nargs=*	MNVFoldr	<args>
 com! -nargs=*	MNVFoldt	<args>
endif

" Deprecated variable options {{{2
if exists("g:mnv_minlines")
 let g:mnvsyn_minlines= g:mnv_minlines
endif
if exists("g:mnv_maxlines")
 let g:mnvsyn_maxlines= g:mnv_maxlines
endif
if exists("g:mnvsyntax_noerror")
 let g:mnvsyn_noerror= g:mnvsyntax_noerror
endif

" Nulls {{{2
" =====
MNV9 syn keyword  mnv9Null	null null_blob null_channel null_class null_dict null_function null_job null_list null_object null_partial null_string null_tuple

" Booleans {{{2
" ========
MNV9 syn keyword mnv9Boolean	true false

" Numbers {{{2
" =======
syn case ignore
syn match	mnvNumber	"\<\d\+\%('\d\+\)*"		skipwhite nextgroup=@mnvComment,mnvSubscript,mnvGlobal,mnvSubst1
syn match	mnvNumber	"\<\d\+\%('\d\+\)*\.\d\+\%(e[+-]\=\d\+\)\="	skipwhite nextgroup=@mnvComment
syn match	mnvNumber	"\<0b[01]\+\%('[01]\+\)*"		skipwhite nextgroup=@mnvComment,mnvSubscript
syn match	mnvNumber	"\<0o\=\o\+\%('\o\+\)*"		skipwhite nextgroup=@mnvComment,mnvSubscript
syn match	mnvNumber	"\<0x\x\+\%('\x\+\)*"		skipwhite nextgroup=@mnvComment,mnvSubscript
syn match	mnvNumber	'\<0z\>'			skipwhite nextgroup=@mnvComment
syn match	mnvNumber	'\<0z\%(\x\x\)\+\%(\.\%(\x\x\)\+\)*'	skipwhite nextgroup=@mnvComment,mnvSubscript
syn case match

" All mnvCommands are contained by mnvIsCommand. {{{2
syn cluster mnvCmdList	contains=mnvAbb,mnvAddress,mnvAt,mnvAutocmd,mnvAugroup,mnvBehave,mnvBreakadd,mnvBreakdel,mnvBreaklist,mnvCall,mnvCatch,mnvCd,mnvCommandModifier,mnvConst,mnvDoautocmd,mnvDebug,mnvDebuggreedy,mnvDef,mnvDefFold,mnvDefer,mnvDelcommand,mnvDelFunction,mnvDoCommand,@mnvEcho,mnvElse,mnvEnddef,mnvEndfunction,mnvEndif,mnvEval,mnvExecute,mnvIsCommand,mnvExtCmd,mnvExFilter,mnvExMark,mnvFiletype,mnvFor,mnvFunction,mnvFunctionFold,mnvGrep,mnvGrepAdd,mnvGlobal,mnvHelp,mnvHelpgrep,mnvHighlight,mnvHistory,mnvImport,mnvLanguage,mnvLet,mnvLoadkeymap,mnvLockvar,mnvMake,mnvMap,mnvMark,mnvMatch,mnvNotFunc,mnvNormal,mnvProfdel,mnvProfile,mnvPrompt,mnvRedir,mnvSet,mnvSleep,mnvSort,mnvSyntax,mnvSyntime,mnvSynColor,mnvSynLink,mnvTerminal,mnvThrow,mnvUniq,mnvUnlet,mnvUnlockvar,mnvUnmap,mnvUserCmd,mnvMNVgrep,mnvMNVgrepadd,mnvWincmd,mnvMenu,mnvMenutranslate,@mnv9CmdList,@mnvExUserCmdList,mnvLua,mnvMzScheme,mnvPerl,mnvPython,mnvPython3,mnvPythonX,mnvRuby,mnvTcl
syn cluster mnv9CmdList	contains=mnv9Abstract,mnv9Class,mnv9Const,mnv9Enum,mnv9Export,mnv9Final,mnv9For,mnv9Interface,mnv9Type,mnv9Var
syn match mnvCmdSep	"\\\@1<!|"	skipwhite nextgroup=@mnvCmdList,mnvSubst1,@mnvFunc
syn match mnvCmdSep	":\+"	skipwhite nextgroup=@mnvCmdList,mnvSubst1
syn match mnvCount	contained	"\d\+"
syn match mnvIsCommand	"\<\h\w*\>"	nextgroup=mnvBang contains=mnvCommand
syn match mnvBang	      contained	"!"
syn match mnvWhitespace contained	"\s\+"

syn region mnvSubscript contained	matchgroup=mnvSubscriptBracket start="\[" end="]" nextgroup=mnvSubscript contains=@mnvExprList

syn match mnvVar	      contained	"\<\h[a-zA-Z0-9#_]*\>"	nextgroup=mnvSubscript contains=mnv9Super,mnv9This
syn match mnvVar		"\<[bwglstav]:\h[a-zA-Z0-9#_]*\>"	nextgroup=mnvSubscript contains=mnvVarScope
syn match mnvVar		"\<a:\%(000\|1\=[0-9]\|20\)\>"	nextgroup=mnvSubscript contains=mnvVarScope
syn match mnvFBVar      contained	"\<[bwglsta]:\h[a-zA-Z0-9#_]*\>"	nextgroup=mnvSubscript contains=mnvVarScope

" match the scope prefix independently of the retrofitted scope dictionary
syn match mnvVarScope   contained	"\<[bwglstav]:"
syn match mnvMNVVar     contained	"\<[bwglstav]:\%(\h\|\d\)\@!"	nextgroup=mnvSubscript

syn match mnvVarNameError contained "\<\h\w*\>"
syn match mnvMNVVar	"\<v:"		nextgroup=mnvSubscript,mnvMNVVarName,mnvVarNameError
syn match mnvOptionVar	"&\%([lg]:\)\="		nextgroup=mnvSubscript,mnvOptionVarName,mnvVarNameError
syn cluster mnvSpecialVar	contains=mnvEnvvar,mnvLetRegister,mnvOptionVar,mnvMNVVar

MNV9 syn match	mnvVar	contained	 "\<\h\w*\ze<"		nextgroup=mnv9TypeArgs

MNV9 syn match	mnv9LhsVariable	"\s\=\h[a-zA-Z0-9#_]*\ze\s\+[-+/*%]\==\%(\s\|$\)"
MNV9 syn match	mnv9LhsVariable	"\s\=\h[a-zA-Z0-9#_]*\ze\s\+\.\.=\%(\s\|$\)"
MNV9 syn match	mnv9LhsVariable	"\s\=\%([bwgt]:\)\=\h[a-zA-Z0-9#_]*\ze\s\+=<<\s"	skipwhite nextgroup=mnvLetHeredoc	contains=mnvVarScope
MNV9 syn match	mnv9LhsVariable	"\s\=\h[a-zA-Z0-9#_]*\ze\["		          nextgroup=mnvSubscript
MNV9 syn match	mnv9LhsVariable	"\s\=\h[a-zA-Z0-9#_]*\ze\."		          nextgroup=mnvOper	contains=mnv9Super,mnv9This
MNV9 syn match	mnv9LhsVariable	"\s\=\h[a-zA-Z0-9#_]*\ze\s*->"				contains=mnv9Super,mnv9This

MNV9 syn match mnv9LhsVariableList	"\[\_[^]]\+]\ze\s\+[-+/*%]\=="			contains=mnvVar,@mnvSpecialVar
MNV9 syn match mnv9LhsVariableList	"\[\_[^]]\+]\ze\s\+=<<"	skipwhite nextgroup=mnvLetHeredoc	contains=mnvVar,@mnvSpecialVar
MNV9 syn match mnv9LhsVariableList	"\[\_[^]]\+]\ze\s\+\.\.="			contains=mnvVar,@mnvSpecialVar

MNV9 syn match mnv9LhsRegister	"@["0-9\-a-zA-Z#=*+_/]\ze\s\+\%(\.\.\)\=="

syn cluster mnvExprList	contains=@mnvSpecialVar,@mnvFunc,mnvNumber,mnvOper,mnvOperParen,mnvLambda,mnvString,mnvVar,@mnv9ExprList
syn cluster mnv9ExprList	contains=mnv9Boolean,mnv9LambdaParams,mnv9Null

" Insertions And Appends: insert append {{{2
"   (buftype != nofile test avoids having append, change, insert show up in the command window)
" =======================
if &buftype != 'nofile'
 syn region mnvInsert	matchgroup=mnvCommand start="^[: \t]*\(\d\+\(,\d\+\)\=\)\=a\%[ppend]$"		matchgroup=mnvCommand end="^\.$" extend
 syn region mnvInsert	matchgroup=mnvCommand start="^[: \t]*\(\d\+\(,\d\+\)\=\)\=c\%[hange]$"		matchgroup=mnvCommand end="^\.$" extend
 syn region mnvInsert	matchgroup=mnvCommand start="^[: \t]*\(\d\+\(,\d\+\)\=\)\=i\%[nsert]$"		matchgroup=mnvCommand end="^\.$" extend
endif

" Behave! {{{2
" =======
if !exists("g:mnvsyn_noerror") && !exists("g:mnvsyn_nobehaveerror")
 syn match   mnvBehaveError contained	"[^ ]\+"
endif
syn match   mnvBehave	"\<be\%[have]\>"	nextgroup=mnvBehaveBang,mnvBehaveModel,mnvBehaveError skipwhite
syn match   mnvBehaveBang	contained	"\a\@1<=!" nextgroup=mnvBehaveModel skipwhite
syn keyword mnvBehaveModel	contained	mswin	xterm

" Break* commands {{{2
" ===============
syn keyword	mnvBreakaddFunc	contained	func	skipwhite nextgroup=mnvBreakpointFunctionLine,mnvBreakpointFunction
syn keyword	mnvBreakaddFile	contained	file	skipwhite nextgroup=mnvBreakpointFileLine,mnvBreakpointFilename
syn keyword	mnvBreakaddHere	contained	here	skipwhite nextgroup=mnvComment,mnv9Comment,mnvSep
syn keyword	mnvBreakaddExpr	contained	expr	skipwhite nextgroup=@mnvExprList

syn match	mnvBreakpointGlob		contained	"*"	skipwhite nextgroup=mnvComment,mnv9Comment,mnvSep
syn match	mnvBreakpointNumber	contained	"\<\d\+\>"	skipwhite nextgroup=mnvComment,mnv9Comment,mnvSep

syn cluster mnvBreakpointArg contains=mnvBreakaddFunc,mnvBreakaddFile,mnvBreakaddHere,mnvBreakaddExpr

syn match	mnvBreakpointFunction	contained	"\<\%(\*\|\w\)\+\>"	skipwhite nextgroup=mnvComment,mnv9Comment,mnvSep
syn match	mnvBreakpointFilename	contained	"\<\%(\*\|\f\)\+\>"	skipwhite nextgroup=mnvComment,mnv9Comment,mnvSep
syn match	mnvBreakpointFunctionLine	contained	"\<\d\+\>"		skipwhite nextgroup=mnvBreakpointFunction
syn match	mnvBreakpointFileLine	contained	"\<\d\+\>"		skipwhite nextgroup=mnvBreakpointFilename

syn keyword	mnvBreakadd	breaka[dd]	skipwhite nextgroup=@mnvBreakpointArg
syn keyword	mnvBreakdel	breakd[el]	skipwhite nextgroup=@mnvBreakpointArg,mnvBreakpointNumber,mnvBreakpointGlob
syn keyword	mnvBreaklist	breakl[ist]	skipwhite nextgroup=mnvComment,mnv9Comment,mnvSep

" Call {{{2
" ====
syn match mnvCall	"\<call\=\>"	skipwhite nextgroup=mnvVar,@mnvFunc

" Cd: {{{2
" ==
" GEN_SYN_MNV: mnvCommand cd, START_STR='syn keyword mnvCd', END_STR='skipwhite nextgroup=mnvCdBang,mnvCdArg,mnvComment,mnv9Comment,mnvCmdSep'
syn match	mnvCd	"\<chd\%[ir]\>"	skipwhite nextgroup=mnvCdBang,mnvCdArg,mnvComment,mnv9Comment,mnvCmdSep
syn region	mnvCdArg	contained
      \ start=+["#|]\@!\S+
      \ end="\ze\s*$"
      \ end=+\ze\s*\\\@1<!["#|]+
      \ skipwhite nextgroup=mnvComment,mnv9Comment,mnvCmdSep
      \ contains=mnvSpecfile,@mnvWildCard
      \ oneline

syn match	mnvCdBang	contained	"\a\@1<=!"	skipwhite nextgroup=mnvCdArg,mnvComment,mnv9Comment,mnvCmdSep

" Debug {{{2
" =====
syn keyword	mnvDebug	deb[ug]	skipwhite nextgroup=@mnvCmdList

" Debuggreedy {{{2
" ===========
" TODO: special-cased until generalised range/count support is implemented
syn match	mnvDebuggreedy	"\<0\=debugg\%[reedy]\>" contains=mnvCount

" Defer {{{2
" =====
syn match	mnvDefer	"\<defer\=\>"	skipwhite nextgroup=@mnvFunc,mnv9LambdaParams

" *Do commands {{{2
" ============
syn match	mnvDoCommandBang	contained	"\a\@1<=!"	skipwhite nextgroup=@mnvCmdList

syn keyword	mnvDoCommand	argdo bufd[o]		skipwhite nextgroup=mnvDoCommandBang,@mnvCmdList
syn keyword	mnvDoCommand	tabd[o] wind[o]		skipwhite nextgroup=@mnvCmdList
syn keyword	mnvDoCommand	cdo cfd[o]		skipwhite nextgroup=mnvDoCommandBang,@mnvCmdList
syn keyword	mnvDoCommand	ld[o] lfd[o]		skipwhite nextgroup=mnvDoCommandBang,@mnvCmdList
syn keyword	mnvDoCommand	foldd[oopen] folddoc[losed]	skipwhite nextgroup=@mnvCmdList

" Exception Handling {{{2
syn keyword	mnvThrow	th[row]	skipwhite nextgroup=@mnvExprList
syn keyword	mnvCatch	cat[ch]	skipwhite nextgroup=mnvCatchPattern
syn region	mnvCatchPattern	contained	matchgroup=Delimiter start="\z([!#$%&'()*+,-./:;<=>?@[\]^_`{}~]\)" skip="\\\\\|\\\z1" end="\z1" contains=@mnvSubstList oneline

" Export {{{2
" ======
if s:mnv9script
  syn keyword	mnv9Export	export	skipwhite nextgroup=mnv9Abstract,mnv9ClassBody,mnv9Const,mnv9Def,mnv9EnumBody,mnv9Final,mnv9InterfaceBody,mnv9Type,mnv9Var
endif

" Filetypes {{{2
" =========
syn match   mnvFiletype	"\<filet\%[ype]\(\s\+\I\i*\)*"	skipwhite contains=mnvFTCmd,mnvFTOption,mnvFTError
if !exists("g:mnvsyn_noerror") && !exists("g:mnvsyn_mnvFTError")
 syn match   mnvFTError  contained	"\I\i*"
endif
syn keyword mnvFTCmd    contained	filet[ype]
syn keyword mnvFTOption contained	detect indent off on plugin

" History {{{2
" =======
" TODO: handle MNV9 "history" variable assignment (like :wincmd, but a common variable name)
syn keyword	mnvHistory	his[tory]	skipwhite nextgroup=mnvHistoryName,mnvHistoryRange,mnvCmdSep,mnvComment,mnv9Comment
syn keyword	mnvHistoryName	contained	c[md] s[earch] e[xpr] i[nput] d[ebug] a[ll]	skipwhite nextgroup=mnvHistoryRange,mnvCmdSep,mnvComment,mnv9Comment
syn match	mnvHistoryName	contained	"[:/?=@>]"			skipwhite nextgroup=mnvHistoryRange,mnvCmdSep,mnvComment,mnv9Comment
syn match	mnvHistoryRange	contained	"-\=\<\d\+\>\%(\s*,\)\="		skipwhite nextgroup=mnvCmdSep,mnvComment,mnv9Comment
syn match	mnvHistoryRange	contained	",\s*-\=\d\+\>"			skipwhite nextgroup=mnvCmdSep,mnvComment,mnv9Comment
syn match	mnvHistoryRange	contained	"-\=\<\d\+\s*,\s*-\=\d\+\>"		skipwhite nextgroup=mnvCmdSep,mnvComment,mnv9Comment

" Import {{{2
" ======
syn keyword	mnvImportAutoload	contained	autoload	skipwhite nextgroup=mnvImportFilename
if s:mnv9script
  syn region	mnvImportFilename contained
        \ start="\S"
        \ skip=+\%#=1
          "\ continuation operators at SOL
          \\n\%(\s*#.*\n\)*\s*\%([[:punct:]]\+\&[^#"'(]\)
            \\|
          "\ continuation operators at EOL
          \\%(\%([[:punct:]]\+\&[^#"')]\)\s*\%(#.*\)\=\)\@<=$
            \\|
          \\n\%(\s*#.*\n\)*\s*as\s
            \\|
          \\%(^\s*#.*\)\@<=$
            \\|
          \\n\s*\%(\\\|#\\ \)
        \+
        \ matchgroup=mnvCommand
        \ end="\s\+\zsas\ze\s\+\h"
        \ matchgroup=NONE
        \ end="$"
        \ skipwhite nextgroup=mnvImportName
        \ contains=@mnv9Continue,@mnvExprList,mnv9Comment
        \ transparent
else
  syn region	mnvImportFilename contained
        \ start="\S"
        \ skip=+\n\s*\%(\\\|"\\ \)+
        \ matchgroup=mnvCommand
        \ end="\s\+\zsas\ze\s\+\h"
        \ matchgroup=NONE
        \ end="$"
        \ skipwhite nextgroup=mnvImportName
        \ contains=@mnvContinue,@mnvExprList
        \ transparent
endif
syn match	mnvImportName	contained	"\%(\<as\s\+\)\@<=\h\w*\>"	skipwhite nextgroup=@mnvComment
syn match	mnvImport		"\<imp\%[ort]\>"		skipwhite nextgroup=mnvImportAutoload,mnvImportFilename

" Language {{{2
" ========
syn keyword 	mnvLanguage		lan[guage]	skipwhite nextgroup=@mnvLanguageName,mnvLanguageCategory,mnvSep,mnvComment,mnv9Comment
syn keyword	mnvLanguageCategory	contained	col[late] cty[pe] mes[sages] tim[e]	skipwhite nextgroup=@mnvLanguageName

" [language[_territory][.codeset][@modifier]] and the reserved "C" and "POSIX"
syn match	mnvLanguageName		contained	"[[:alnum:]][[:alnum:]._@-]*[[:alnum:]]"	nextgroup=mnvSep,mnvComment,mnv9Comment
syn keyword	mnvLanguageNameReserved	contained	C POSIX			nextgroup=mnvSep,mnvComment,mnv9Comment
syn cluster	mnvLanguageName	contains=mnvLanguageName,mnvLanguageNameReserved

" Augroup : mnvAugroupError removed because long augroups caused sync'ing problems. {{{2
" ======= : Trade-off: Increasing synclines with slower editing vs augroup END error checking.
syn cluster mnvAugroupList	contains=@mnvCmdList,mnvFilter,@mnvFunc,mnvLineComment,mnvSpecFile,mnvOper,mnvNumber,mnvOperParen,@mnvComment,mnvString,mnvSubst,mnvRegister,mnvCmplxRepeat,mnvNotation,mnvCtrlChar,mnvContinue

" define
MNVFolda syn region mnvAugroup
      \ start="\<aug\%[roup]\>\ze\s\+\%([eE][nN][dD]\%($\|[[:space:]|"#]\)\)\@!\S"
      \ matchgroup=mnvAugroupKey
      \ end="\<aug\%[roup]\ze\s\+[eE][nN][dD]\s*\%($\|[|"#]\)"
      \ skipwhite nextgroup=mnvAugroupEnd
      \ contains=mnvAutocmd,@mnvAugroupList,mnvAugroupkey
if !exists("g:mnvsyn_noerror") && !exists("g:mnvsyn_noaugrouperror")
  syn match	mnvAugroupError	"\<aug\%[roup]\s\+[eE][nN][dD]\ze\s*\%($\|[|"#]\)"
endif

" TODO: MNV9 comment
syn match	mnvAugroupName	contained	"\%(\\["|[:space:]]\|[^"|[:space:]]\)\+"
      \                                                                 skipwhite nextgroup=mnvCmdSep,mnvComment
syn match	mnvAugroupEnd	contained	"\c\<END\>"	skipwhite nextgroup=mnvCmdSep,mnvComment
syn match	mnvAugroupBang	contained	"\a\@1<=!"	skipwhite nextgroup=mnvAugroupName
syn keyword	mnvAugroupKey	contained	aug[roup] 	skipwhite nextgroup=mnvAugroupBang,mnvAugroupName,mnvAugroupEnd

" remove
syn match	mnvAugroup	"\<aug\%[roup]!"		skipwhite nextgroup=mnvAugroupName contains=mnvAugroupKey,mnvAugroupBang

" list
MNVL syn match	mnvAugroup	"\<aug\%[roup]\>\ze\s*\%(["|]\|$\)"	skipwhite nextgroup=mnvCmdSep,mnvComment  contains=mnvAugroupKey
MNV9 syn match 	mnvAugroup	"\<aug\%[roup]\>\ze\s*\%([#|]\|$\)"	skipwhite nextgroup=mnvCmdSep,mnv9Comment contains=mnvAugroupKey

" Operators: {{{2
" =========
syn cluster	mnvOperGroup	contains=@mnvContinue,@mnvExprList,mnv9Comment,mnv9LineComment,mnvContinueString
syn match	mnvOper	"\a\@<!!"			skipwhite skipnl nextgroup=@mnvOperContinue,@mnvExprList,mnvSpecFile
syn match	mnvOper	"||\|&&\|[-+*/%.]"		skipwhite skipnl nextgroup=@mnvOperContinue,@mnvExprList,mnvSpecFile
syn match	mnvOper	"?"			skipwhite skipnl nextgroup=@mnvOperContinue,@mnvExprList,mnvContinueString
" distinguish ternary : from ex-colon
syn match	mnvOper	"\s\@1<=:\ze\s\|\s\@1<=:$"		skipwhite skipnl nextgroup=@mnvOperContinue,@mnvExprList,mnvContinueString
syn match	mnvOper	"??"			skipwhite skipnl nextgroup=@mnvOperContinue,@mnvExprList,mnvContinueString
syn match	mnvOper	"="			skipwhite skipnl nextgroup=@mnvOperContinue,@mnvExprList,mnvContinueString,mnvSpecFile
syn match	mnvOper	"\%#=1\%(==\|!=\|>=\|<=\|=\~\|!\~\|>\|<\)[?#]\="	skipwhite skipnl nextgroup=@mnvOperContinue,@mnvExprList,mnvContinueString,mnvSpecFile
syn match	mnvOper	"\<is\%(not\)\=\>"		skipwhite skipnl nextgroup=@mnvOperContinue,@mnvExprList,mnvContinueString,mnvSpecFile
syn match	mnvOper	"\<is\%(not\)\=[?#]"		skipwhite skipnl nextgroup=@mnvOperContinue,@mnvExprList,mnvContinueString,mnvSpecFile
syn region	mnvOperParen 		matchgroup=mnvParenSep start="("    end=")" contains=@mnvOperGroup nextgroup=mnvSubscript
syn region	mnvOperParen		matchgroup=mnvSep	     start="#\={" end="}" contains=@mnvOperGroup nextgroup=mnvSubscript,mnvVar
syn region	mnvOperParen	contained	matchgroup=mnvSep	     start="\["	end="]" contains=@mnvOperGroup nextgroup=mnvSubscript,mnvVar
if !exists("g:mnvsyn_noerror") && !exists("g:mnvsyn_noopererror")
 syn match	mnvOperError	")"
endif

syn match	mnvOperContinue		contained	"^\s*\\"        skipwhite skipnl nextgroup=@mnvOperContinue,@mnvExprList contains=mnvWhitespace
syn match         mnvOperContinueComment	contained	'^\s*["#]\\ .*' skipwhite skipnl nextgroup=@mnvOperContinue,@mnvExprList contains=mnvWhitespace
syn cluster	mnvOperContinue		contains=mnvOperContinue,mnvOperContinueComment

" Lambda Expressions: {{{2
" ==================
syn match	mnvLambdaOperator	contained	"->" skipwhite nextgroup=@mnvExprList
syn region	mnvLambda	contained
      \ matchgroup=mnvLambdaBrace
      \ start=+{\ze[[:space:][:alnum:]_.,]*\%(\n\s*\%(\\[[:space:][:alnum:]_.,]*\|"\\ .*\)\)*->+
      \ skip=+\n\s*\%(\\\|"\\ \)+
      \ end="}" end="$"
      \ contains=@mnvContinue,@mnvExprList,mnvLambdaParams
syn match	mnvLambdaParams	contained	"\%({\n\=\)\@1<=\_.\{-}\%(->\)\@=" nextgroup=mnvLambdaOperator contains=@mnvContinue,mnvFunctionParam

syn match	mnv9LambdaOperator   contained	"=>" skipwhite skipempty nextgroup=@mnvExprList,mnv9LambdaBlock,mnv9LambdaOperatorComment
syn match	mnv9LambdaParen      contained	"[()]"
syn match	mnv9LambdaParams	   contained
      \ "(\%(\<func(\|[^(]\)*\%(\n\s*\\\%(\<func(\|[^(]\)*\|\n\s*#\\ .*\)*\ze\s\+=>"
      \ skipwhite nextgroup=mnv9LambdaOperator
      \ contains=@mnv9Continue,mnvDefParam,mnv9LambdaParen,mnv9LambdaReturnType
syn region	mnv9LambdaReturnType contained	start=")\@<=:\s" end="\ze\s*#" end="\ze\s*=>" contains=@mnv9Continue,@mnvType transparent
syn region	mnv9LambdaBlock	   contained	matchgroup=mnvSep start="{" end="^\s*\zs}" contains=@mnvDefBodyList

syn match	mnv9LambdaOperatorComment contained "#.*" skipwhite skipempty nextgroup=@mnvExprList,mnv9LambdaBlock,mnv9LambdaOperatorComment

" Functions: Tag is provided for those who wish to highlight tagged functions {{{2
" =========
syn cluster	mnvFunctionBodyCommon	contains=@mnvCmdList,mnvCmplxRepeat,mnvContinue,mnvCtrlChar,mnvDef,mnvFBVar,mnvFunction,mnvNotFunc,mnvNumber,mnvOper,mnvOperParen,mnvRegister,mnvSpecFile,mnvString,mnvSubst,mnvFunctionFold,mnvDefFold,mnvCmdSep
syn cluster	mnvFunctionBodyList	contains=@mnvFunctionBodyCommon,mnvComment,mnvLineComment,mnvInsert,mnvConst,mnvLet,mnvSearch
syn cluster	mnvDefBodyList		contains=@mnvFunctionBodyCommon,mnv9Comment,mnv9LineComment,mnv9Block,mnv9Const,mnv9Final,mnv9Var,mnv9Null,mnv9Boolean,mnv9For,mnv9LhsVariable,mnv9LhsVariableList,mnv9LhsRegister,mnv9Search,@mnvSpecialVar,@mnv9Func

syn region	mnvFunctionPattern	contained
      \ matchgroup=mnvOper
      \ start="/"
      \ end="$"
      \ contains=@mnvSubstList

syn match	mnvFunctionBang	contained	"\a\@1<=!"	skipwhite nextgroup=mnvFunctionName
syn match	mnvDefBang	contained	"\a\@1<=!"	skipwhite nextgroup=mnvDefName
syn match	mnvFunctionSID	contained	"\c<sid>"
syn match	mnvFunctionScope	contained	"\<[bwglstav]:"
syn match	mnvFunctionName	contained
      \ "\%(<[sS][iI][dD]>\|[bwglstav]:\)\=\%([[:alnum:]_#.]\+\|{.\{-1,}}\)\+"
      \ skipwhite nextgroup=mnvFunctionParams,mnvCmdSep,mnvComment,mnv9Comment
      \ contains=mnvFunctionError,mnvFunctionScope,mnvFunctionSID,Tag
syn match	mnvDefName	contained
      \ "\%(<[sS][iI][dD]>\|[bwglstav]:\)\=\%([[:alnum:]_#.]\+\|{.\{-1,}}\)\+"
      \ nextgroup=mnvDefTypeParams,mnvDefParams,mnvCmdSep,mnvComment,mnv9Comment
      \ contains=mnvFunctionError,mnvFunctionScope,mnvFunctionSID,Tag

syn match	mnvFunction	"\<fu\%[nction]\>"	skipwhite nextgroup=mnvFunctionBang,mnvFunctionName,mnvFunctionPattern,mnvCmdSep,mnvComment
syn match	mnvDef	"\<def\>"		skipwhite nextgroup=mnvDefBang,mnvDefName,mnvFunctionPattern,mnvCmdSep,mnvComment

syn region	mnvFunctionComment	contained
      \ start=+".*+
      \ skip=+\n\s*\%(\\\|"\\ \)+
      \ end="$"
      \ skipwhite skipempty nextgroup=mnvFunctionBody,mnvEndfunction
syn region	mnvDefComment	contained
      \ start="#.*"
      \ skip=+\n\s*\%(\\\|#\\ \)+
      \ end="$"
      \ skipwhite skipempty nextgroup=mnvDefBody,mnvEnddef

syn region	mnvFunctionParams	contained
      \ matchgroup=Delimiter
      \ start="("
      \ skip=+\n\s*\%(\\\|"\\ \)+
      \ end=")"
      \ skipwhite skipempty nextgroup=mnvFunctionBody,mnvFunctionComment,mnvEndfunction,mnvFunctionMod,mnv9CommentError
      \ contains=mnvFunctionParam,mnvOperParen,@mnvContinue
syn region	mnvDefParams	contained
      \ matchgroup=Delimiter
      \ start="("
      \ end=")"
      \ skipwhite skipempty nextgroup=mnvDefBody,mnvDefComment,mnvEnddef,mnvReturnType,mnvCommentError
      \ contains=mnvDefParam,mnv9Comment,mnvFunctionParamEquals,mnvOperParen
syn region	mnvDefTypeParams	contained
      \ matchgroup=Delimiter
      \ start="<"
      \ end=">"
      \ nextgroup=mnvDefParams
      \ contains=mnv9DefTypeParam
syn match	mnvFunctionParam	contained	"\<\h\w*\>\|\.\.\."	skipwhite nextgroup=mnvFunctionParamEquals
syn match	mnvDefParam	contained	"\<\h\w*\>"		skipwhite nextgroup=mnvParamType,mnvFunctionParamEquals
syn match	mnv9DefTypeParam	contained	"\<\u\w*\>"

syn match	mnvFunctionParamEquals contained	"="			skipwhite	  nextgroup=@mnvExprList
syn match	mnvFunctionMod	     contained	"\<\%(abort\|closure\|dict\|range\)\>"	skipwhite skipempty nextgroup=mnvFunctionBody,mnvFunctionComment,mnvEndfunction,mnvFunctionMod,mnv9CommentError

syn region	mnvFunctionBody	contained
      \ start="^."
      \ matchgroup=mnvCommand
      \ end="\<endfu\%[nction]\>"
      \ skipwhite nextgroup=mnvCmdSep,mnvComment,mnv9CommentError
      \ contains=@mnvFunctionBodyList
syn region	mnvDefBody	contained
      \ start="^."
      \ matchgroup=mnvCommand
      \ end="\<enddef\>"
      \ skipwhite nextgroup=mnvCmdSep,mnv9Comment,mnvCommentError
      \ contains=@mnvDefBodyList

syn match	mnvEndfunction	"\<endf\%[unction]\>"	skipwhite nextgroup=mnvCmdSep,mnvComment,mnv9CommentError
syn match	mnvEnddef	"\<enddef\>"		skipwhite nextgroup=mnvCmdSep,mnv9Comment,mnvCommentError

if exists("g:mnvsyn_folding") && g:mnvsyn_folding =~# 'f'
  syn region	mnvFunctionFold
        \ start="\<fu\%[nction]!"
        "\ assume no dict literal in curly-brace name expressions
        \ start="\<fu\%[nction]\>\s*\%([[:alnum:]_:<>.#]\+\|{.\{-1,}}\)\+\s*("
        \ end="^\s*:\=\s*endf\%[unction]\>"
        \ contains=mnvFunction
        \ extend fold keepend transparent
  syn region	mnvDefFold
        \ start="\<def!"
        "\ assume no dict literal in curly-brace name expressions
        \ start="\<def\>\s*\%([[:alnum:]_:<>.#]\+\|{.\{-1,}}\)\+[<(]"
        \ end="^\s*:\=\s*enddef\>"
        \ contains=mnvDef
        \ extend fold keepend transparent
endif

syn match	mnvDelfunctionBang	contained	"\a\@1<=!"		skipwhite nextgroup=mnvFunctionName
syn match	mnvDelfunction			"\<delf\%[unction]\>"	skipwhite nextgroup=mnvDelfunctionBang,mnvFunctionName

" Types: {{{2
" =====

syn region	mnvReturnType	contained
      \ start=":\%(\s\|\n\)\@="
      \ skip=+\n\s*\%(\\\|#\\ \)\|^\s*#\\ +
      \ end="$"
      \ matchgroup=mnv9Comment
      "\ allow for legacy script tail comment error
      \ end="\ze[#"]"
      \ skipwhite skipempty nextgroup=mnvDefBody,mnvDefComment,mnvEnddef,mnvCommentError
      \ contains=@mnv9Continue,@mnvType
      \ transparent
syn match	mnvParamType	contained	":\s"	skipwhite skipnl nextgroup=@mnvType contains=mnvTypeSep

syn match	mnvTypeSep	contained	":\%(\s\|\n\)\@=" skipwhite nextgroup=@mnvType
syn keyword	mnvType	contained	blob bool channel float job number string void
syn keyword	mnvTypeAny	contained	any
syn match	mnvTypeObject	contained	"\<object<\@="	nextgroup=mnvTypeObjectArgs
syn region	mnvTypeObjectArgs	contained
      \ matchgroup=mnvTypeObjectBracket
      \ start="<"
      \ end=">"
      \ contains=mnvTypeAny,mnvTypeObject,mnvUserType
      \ oneline
      \ transparent
syn match	mnvType	contained	"\<\%(func\)\>"
syn region	mnvCompoundType	contained	matchgroup=mnvType start="\<func("	          end=")" nextgroup=mnvTypeSep contains=@mnv9Continue,@mnvType transparent
syn region	mnvCompoundType	contained	matchgroup=mnvType start="\<tuple<"           end=">"                      contains=@mnv9Continue,@mnvType transparent
syn region	mnvCompoundType	contained	matchgroup=mnvType start="\<\%(list\|dict\)<" end=">"		   contains=@mnvType oneline       transparent
syn match	mnvUserType	contained	"\<\%(\h\w*\.\)*\u\w*\>"

syn cluster mnvType contains=mnvType,mnvTypeAny,mnvTypeObject,mnvCompoundType,mnvUserType

" Classes, Enums And Interfaces: {{{2
" =============================

if s:mnv9script

  " Methods {{{3
  syn match	mnv9MethodDef		contained	"\<def\>"	skipwhite nextgroup=mnv9MethodDefName,mnv9ConstructorDefName
  syn match	mnv9MethodDefName		contained	"\<\h\w*\>"	nextgroup=mnv9MethodDefParams,mnv9MethodDefTypeParams contains=@mnv9MethodName
  syn region	mnv9MethodDefParams	contained
        \ matchgroup=Delimiter start="(" end=")"
        \ skipwhite skipnl nextgroup=mnv9MethodDefBody,mnv9MethodDefComment,mnvEnddef,mnv9MethodDefReturnType,mnvCommentError
        \ contains=mnvDefParam,mnv9Comment,mnvFunctionParamEquals
  syn region	mnv9MethodDefTypeParams	contained
        \ matchgroup=Delimiter
        \ start="<"
        \ end=">"
        \ nextgroup=mnv9MethodDefParams
        \ contains=mnv9DefTypeParam

  syn match	mnv9ConstructorDefName	contained	"\<_\=new\w*\>"
        \ nextgroup=mnv9ConstructorDefParams,mnv9ConstuctorDefTypeParams
        \ contains=@mnv9MethodName
  syn match	mnv9ConstructorDefParam	contained	"\<\%(this\.\)\=\h\w*\>"
        \ skipwhite nextgroup=mnvParamType,mnvFunctionParamEquals
        \ contains=mnv9This,mnvOper
  syn region	mnv9ConstructorDefParams	contained
        \ matchgroup=Delimiter start="(" end=")"
        \ skipwhite skipnl nextgroup=mnv9MethodDefBody,mnv9MethodDefComment,mnvEnddef,mnvCommentError
        \ contains=mnv9ConstructorDefParam,mnv9Comment,mnvFunctionParamEquals
  syn region	mnv9ConstuctorDefTypeParams	contained
        \ matchgroup=Delimiter
        \ start="<"
        \ end=">"
        \ nextgroup=mnv9ConstructorDefParams
        \ contains=mnv9DefTypeParam

  syn region	mnv9MethodDefReturnType	contained
        \ start=":\%(\s\|\n\)\@="
        \ skip=+\n\s*\%(\\\|#\\ \)\|^\s*#\\ +
        \ end="$"
        \ matchgroup=mnv9Comment
        \ end="\ze#"
        \ skipwhite skipnl nextgroup=mnv9MethodDefBody,mnv9MethodDefComment,mnvEnddef,mnvCommentError
        \ contains=@mnv9Continue,mnvType,mnvTypeSep
        \ transparent

  syn region	mnv9MethodDefComment	contained
        \ start="#.*"
        \ skip=+\n\s*\%(\\\|#\\ \)+
        \ end="$"
        \ skipwhite skipempty nextgroup=mnv9MethodDefBody,mnvEnddef

  syn region	mnv9MethodDefBody		contained
        \ start="^.\=" matchgroup=mnvCommand end="\<enddef\>"
        \ skipwhite nextgroup=mnvCmdSep,mnv9Comment,mnvCommentError
        \ contains=@mnv9MethodDefBodyList

  syn cluster	mnv9MethodDefBodyList contains=@mnvDefBodyList,mnv9This,mnv9Super

  if !exists("g:mnvsyn_noerror") && !exists("g:mnvsyn_nomnvfunctionerror")
    syn match	mnv9MethodNameError contained	"\<[a-z0-9]\i\>"
  endif
  syn match	mnv9MethodName	contained	"\<_\=new\w*\>"
  syn keyword	mnv9MethodName	contained	empty len string

  syn cluster	mnv9MethodName	contains=mnv9MethodName,mnv9MethodNameError

  if exists("g:mnvsyn_folding") && g:mnvsyn_folding =~# 'f'
    syn region	mnv9MethodDefFold	contained
          \ start="\%(^\s*\%(:\=static\s\+\)\=\)\@16<=:\=def\s\+\h\w*[<(]"
          \ end="^\s*:\=enddef\>"
          \ contains=mnv9MethodDef
          \ fold keepend extend transparent
  endif

  syn cluster mnv9MethodDef contains=mnv9MethodDef,mnv9MethodDefFold

  " Classes {{{3
  syn cluster	mnv9ClassBodyList		contains=mnv9Abstract,mnv9Class,mnv9Comment,mnv9LineComment,@mnv9Continue,@mnvExprList,mnv9Extends,mnv9Implements,@mnv9MethodDef,mnv9Public,mnv9Static,mnv9Const,mnv9Final,mnv9This,mnv9Super,mnv9Var

  syn match	mnv9Class		contained	"\<class\>"	skipwhite        nextgroup=mnv9ClassName
  syn match	mnv9ClassName		contained	"\<\u\w*\>"	skipwhite skipnl nextgroup=mnv9Extends,mnv9Implements
  syn match	mnv9SuperClass		contained	"\<\u\w*\>"	skipwhite skipnl nextgroup=mnv9Implements
  syn match	mnv9ImplementedInterface	contained	"\<\u\w*\>"	skipwhite skipnl nextgroup=mnv9InterfaceListComma,mnv9Extends
  syn match	mnv9InterfaceListComma	contained	","	skipwhite skipnl nextgroup=mnv9ImplementedInterface
  syn keyword	mnv9Abstract			abstract	skipwhite skipnl nextgroup=mnv9ClassBody,mnv9AbstractDef
  syn keyword	mnv9Extends		contained	extends	skipwhite skipnl nextgroup=mnv9SuperClass
  syn keyword	mnv9Implements		contained	implements	skipwhite skipnl nextgroup=mnv9ImplementedInterface
  syn keyword	mnv9Public		contained	public
  syn keyword	mnv9Static		contained	static
  " FIXME: don't match as dictionary keys, remove when operators are not
  "        shared between MNV9 and legacy script
  syn match	mnv9This		contained	"\.\@1<!\<this\>:\@!"
  " super must be followed by '.'
  syn match	mnv9Super		contained	"\.\@1<!\<super\.\@="

  MNVFoldc syn region	mnv9ClassBody	start="\<class\>" matchgroup=mnvCommand end="\<endclass\>" contains=@mnv9ClassBodyList transparent

  " Enums {{{3
  syn cluster	mnv9EnumBodyList		contains=mnv9Comment,mnv9LineComment,@mnv9Continue,mnv9Enum,@mnvExprList,@mnv9MethodDef,mnv9Public,mnv9Static,mnv9Const,mnv9Final,mnv9This,mnv9Var

  syn match	mnv9Enum		contained	"\<enum\>"	skipwhite           nextgroup=mnv9EnumName

  syn match	mnv9EnumName		contained	"\<\u\w*\>"	skipwhite skipempty nextgroup=mnv9EnumNameTrailing,mnv9EnumNameEmpty,mnv9EnumNameComment,@mnv9EnumNameContinue,mnv9EnumImplements
  syn match	mnv9EnumNameTrailing	contained	"\S.*"
  syn region	mnv9EnumNameComment	contained
        \ start="#" skip="\n\s*\%(\\\|#\\ \)" end="$"
        \ skipwhite skipempty nextgroup=mnv9EnumNameComment,mnv9EnumValue
        \ contains=@mnvCommentGroup,mnvCommentString
  " mnv9EnumName's "skipempty" should only apply to comments and enum values and not implements clauses
  syn match	mnv9EnumNameEmpty		contained	"^"	skipwhite skipempty nextgroup=mnv9EnumNameComment,mnv9EnumValue
  " allow line continuation between enum name and "implements"
  syn match	mnv9EnumNameContinue	contained
        \ "^\s*\\"
        \ skipwhite skipnl nextgroup=mnv9EnumNameTrailing,mnv9EnumNameEmpty,mnv9EnumNameComment,@mnv9EnumNameContinue,mnv9EnumImplements
        \ contains=mnvWhitespace
  syn match	mnv9EnumNameContinueComment	contained
        \ "^\s*#\\ .*"
        \ skipwhite skipnl nextgroup=mnv9EnumNameEmpty,mnv9EnumNameComment,@mnv9EnumNameContinue
        \ contains=mnvWhitespace
  syn cluster	mnv9EnumNameContinue	contains=mnv9EnumNameContinue,mnv9EnumNameContinueComment

  " enforce enum value list location
  syn match	mnv9EnumValue		contained	"\<\a\w*\>"		  nextgroup=mnv9EnumValueTypeArgs,mnv9EnumValueArgList,mnv9EnumValueListComma,mnv9Comment
  syn match	mnv9EnumValueListComma	contained	","	skipwhite skipempty nextgroup=mnv9EnumValue,mnv9EnumValueListCommaComment
  syn region	mnv9EnumValueListCommaComment	contained
        \ start="#" skip="\n\s*\%(\\\|#\\ \)" end="$"
        \ skipwhite skipempty nextgroup=mnv9EnumValueListCommaComment,mnv9EnumValue
        \ contains=@mnvCommentGroup,mnvCommentString
  syn region	mnv9EnumValueTypeArgs	contained
        \ matchgroup=Delimiter
        \ start="<\ze\a"
        \ end=">"
        \ nextgroup=mnv9EnumValueArgList
        \ contains=@mnvType
        \ oneline
  syn region	mnv9EnumValueArgList	contained
        \ matchgroup=mnvParenSep start="(" end=")"
        \ nextgroup=mnv9EnumValueListComma
        \ contains=@mnvExprList,mnvContinueString,mnv9Comment

  syn keyword	mnv9EnumImplements	contained	implements	skipwhite        nextgroup=mnv9EnumImplementedInterface
  syn match	mnv9EnumImplementedInterface	contained	"\<\u\w*\>"	skipwhite skipnl nextgroup=mnv9EnumInterfaceListComma,mnv9EnumImplementedInterfaceComment,mnv9EnumValue
  syn match	mnv9EnumInterfaceListComma	contained	","	skipwhite        nextgroup=mnv9EnumImplementedInterface
  syn region	mnv9EnumImplementedInterfaceComment	contained
        \ start="#" skip="\n\s*\%(\\\|#\\ \)" end="$"
        \ skipwhite skipempty nextgroup=mnv9EnumImplementedInterfaceComment,mnv9EnumValue
        \ contains=@mnvCommentGroup,mnvCommentString

  MNVFolde syn region	mnv9EnumBody	start="\<enum\>" matchgroup=mnvCommand end="\<endenum\>" contains=@mnv9EnumBodyList transparent

  " Interfaces {{{3
  " TODO: limit to decl only - no init values
  syn cluster	mnv9InterfaceBodyList	contains=mnv9Comment,mnv9LineComment,@mnv9Continue,mnv9Extends,mnv9Interface,mnv9AbstractDef,mnv9Var

  syn match	mnv9Interface		contained	"\<interface\>"	skipwhite nextgroup=mnv9InterfaceName
  syn match	mnv9InterfaceName		contained	"\<\u\w*\>"	skipwhite skipnl nextgroup=mnv9Extends

  syn keyword	mnv9AbstractDef		contained	def	skipwhite nextgroup=mnv9AbstractDefName
  syn match	mnv9AbstractDefName	contained	"\<\h\w*\>"	skipwhite nextgroup=mnv9AbstractDefParams,mnv9AbstractDefTypeParams contains=@mnv9MethodName
  syn region	mnv9AbstractDefParams	contained
        \ matchgroup=Delimiter start="(" end=")"
        \ skipwhite skipnl nextgroup=mnvDefComment,mnv9AbstractDefReturnType,mnvCommentError
        \ contains=mnvDefParam,mnv9Comment,mnvFunctionParamEquals
  syn region	mnv9AbstractDefReturnType	contained
        \ start=":\s" end="$" matchgroup=mnv9Comment end="\ze[#"]"
        \ skipwhite skipnl nextgroup=mnvDefComment,mnvCommentError
        \ contains=mnvTypeSep
        \ transparent
  syn region	mnv9AbstractDefTypeParams	contained
        \ matchgroup=Delimiter
        \ start="<"
        \ end=">"
        \ nextgroup=mnv9AbstractDefParams
        \ contains=mnv9DefTypeParam

  MNVFoldi syn region	mnv9InterfaceBody	start="\<interface\>" matchgroup=mnvCommand end="\<endinterface\>" contains=@mnv9InterfaceBodyList transparent

  " Type Aliases {{{3
  syn match	mnv9Type		"\<ty\%[pe]\>"	skipwhite nextgroup=mnv9TypeAlias,mnv9TypeAliasError
  syn match	mnv9TypeAlias	 contained	"\<\u\w*\>"	skipwhite nextgroup=mnv9TypeEquals
  syn match	mnv9TypeEquals	 contained	"="	skipwhite nextgroup=@mnvType
  if !exists("g:mnvsyn_noerror") && !exists("g:mnvsyn_notypealiaserror")
    syn match	mnv9TypeAliasError contained	"\<\l\w*\>"	skipwhite nextgroup=mnv9TypeEquals
  endif
endif

" Blocks: {{{2
" ======
MNV9 syn region	mnv9Block
      \ matchgroup=mnvSep
      \ start="{\ze\s*\%($\|[#|]\)"
      \ end="^\s*\zs}"
      \ skipwhite nextgroup=mnv9Comment,mnvCmdSep
      \ contains=@mnvDefBodyList

" Keymaps: {{{2
" =======

syn match  mnvKeymapStart	"^"	contained skipwhite nextgroup=mnvKeymapLhs,@mnvKeymapLineComment
syn match  mnvKeymapLhs	"\S\+"	contained skipwhite nextgroup=mnvKeymapRhs contains=mnvNotation
syn match  mnvKeymapRhs	"\S\+"	contained skipwhite nextgroup=mnvKeymapTailComment contains=mnvNotation
syn match  mnvKeymapTailComment	"\S.*"	contained

" TODO: remove when :" comment is matched in parts as "ex-colon comment" --djk
if s:mnv9script
  syn match  mnv9KeymapLineComment	"#.*"	contained contains=@mnvCommentGroup,mnvCommentString,mnv9CommentTitle
else
  syn match  mnvKeymapLineComment	+".*+	contained contains=@mnvCommentGroup,mnvCommentString,mnvCommentTitle
endif
syn cluster mnvKeymapLineComment contains=mnv9\=KeymapLineComment

syn region mnvLoadkeymap matchgroup=mnvCommand start="\<loadk\%[eymap]\>" end="\%$" contains=mnvKeymapStart

" Special Filenames, Modifiers, Extension Removal: {{{2
" ===============================================
syn match	mnvSpecFile	"<c\(word\|WORD\)>"	nextgroup=mnvSpecFileMod,mnvSubst1
syn match	mnvSpecFile	"<\([acs]file\|amatch\|abuf\)>"	nextgroup=mnvSpecFileMod,mnvSubst1
syn match	mnvSpecFile	"\s%[ \t:]"ms=s+1,me=e-1	nextgroup=mnvSpecFileMod,mnvSubst1
syn match	mnvSpecFile	"\s%$"ms=s+1		nextgroup=mnvSpecFileMod,mnvSubst1
syn match	mnvSpecFile	"\s%<"ms=s+1,me=e-1	nextgroup=mnvSpecFileMod,mnvSubst1
syn match	mnvSpecFile	"#\d\+\|[#%]<\>"		nextgroup=mnvSpecFileMod,mnvSubst1
syn match	mnvSpecFileMod	"\(:[phtre]\)\+"	contained

syn match	mnvSpecFile	contained		"%[ \t:]"me=e-1	nextgroup=mnvSpecFileMod
syn match	mnvSpecFile	contained	excludenl	"%$"	nextgroup=mnvSpecFileMod
syn match	mnvSpecFile	contained		"%<"me=e-1	nextgroup=mnvSpecFileMod

" User-Specified Commands: {{{2
" =======================
syn cluster	mnvUserCmdList	contains=@mnvCmdList,mnvCmplxRepeat,@mnvComment,mnvCtrlChar,mnvEscapeBrace,@mnvFunc,mnvNotation,mnvNumber,mnvOper,mnvRegister,mnvSpecFile,mnvString,mnvSubst,mnvSubstRep,mnvSubstRange

syn match	mnvUserCmd	"\<com\%[mand]\>!\="		skipwhite        nextgroup=mnvUserCmdAttrs,mnvUserCmdName contains=mnvBang
syn match	mnvUserCmd	+\<com\%[mand]\>!\=\ze\s*\n\s*\%(\\\|["#]\\ \)+	skipwhite skipnl nextgroup=mnvUserCmdAttrs,mnvUserCmdName contains=mnvBang

syn region	mnvUserCmdAttrs	    contained
      \ start="-\l"
      \ start=+^\s*\%(\\\|["#]\\ \)+
      \ end="\ze\s\u"
      \ skipwhite nextgroup=mnvUserCmdName
      \ contains=@mnvContinue,mnvUserCmdAttr,mnvUserCmdAttrError
      \ transparent
syn match	mnvUserCmdAttrError contained	"-\a\+\ze\%(\s\|=\)"
syn match	mnvUserCmdAttr	  contained	"-addr="		contains=mnvUserCmdAttrKey nextgroup=mnvUserCmdAttrAddr
syn match	mnvUserCmdAttr	  contained	"-bang\>"		contains=mnvUserCmdAttrKey
syn match	mnvUserCmdAttr	  contained	"-bar\>"		contains=mnvUserCmdAttrKey
syn match	mnvUserCmdAttr	  contained	"-buffer\>"		contains=mnvUserCmdAttrKey
syn match	mnvUserCmdAttr	  contained	"-complete="		contains=mnvUserCmdAttrKey nextgroup=mnvUserCmdAttrComplete,mnvUserCmdError
syn match	mnvUserCmdAttr	  contained	"-count\>"		contains=mnvUserCmdAttrKey
syn match	mnvUserCmdAttr	  contained	"-count="		contains=mnvUserCmdAttrKey nextgroup=mnvNumber
syn match	mnvUserCmdAttr	  contained	"-keepscript\>"		contains=mnvUserCmdAttrKey
syn match	mnvUserCmdAttr	  contained	"-nargs="		contains=mnvUserCmdAttrKey nextgroup=mnvUserCmdAttrNargs
syn match	mnvUserCmdAttr	  contained	"-range\>"		contains=mnvUserCmdAttrKey
syn match	mnvUserCmdAttr	  contained	"-range="		contains=mnvUserCmdAttrKey nextgroup=mnvNumber,mnvUserCmdAttrRange
syn match	mnvUserCmdAttr	  contained	"-register\>"		contains=mnvUserCmdAttrKey

syn match	mnvUserCmdAttrNargs	contained	"[01*?+]"
syn match	mnvUserCmdAttrRange	contained	"%"

if !exists("g:mnvsyn_noerror") && !exists("g:mnvsyn_nousercmderror")
 syn match	mnvUserCmdError	contained	"\S\+\>"
endif

syn case ignore
syn keyword	mnvUserCmdAttrKey   contained	a[ddr] ban[g] bar bu[ffer] com[plete] cou[nt] k[eepscript] n[args] ra[nge] re[gister]

" GEN_SYN_MNV: mnvUserCmdAttrComplete, START_STR='syn keyword mnvUserCmdAttrComplete contained', END_STR=''
syn keyword mnvUserCmdAttrComplete contained arglist augroup behave breakpoint buffer color command compiler cscope diff_buffer dir dir_in_path environment event expression file file_in_path filetype function help highlight history keymap locale mapclear mapping menu messages option packadd runtime scriptnames shellcmd shellcmdline sign syntax syntime tag tag_listfiles user var
syn keyword	mnvUserCmdAttrComplete	contained	custom customlist nextgroup=mnvUserCmdAttrCompleteFunc,mnvUserCmdError
syn match	mnvUserCmdAttrCompleteFunc	contained	",\%([bwglstav]:\|<[sS][iI][dD]>\)\=\h\w*\%([.#]\h\w*\)*"hs=s+1 nextgroup=mnvUserCmdError contains=mnvVarScope,mnvFunctionSID

" GEN_SYN_MNV: mnvUserCmdAttrAddr, START_STR='syn keyword mnvUserCmdAttrAddr contained', END_STR=''
syn keyword mnvUserCmdAttrAddr contained arguments arg buffers buf lines line loaded_buffers load other quickfix qf tabs tab windows win
syn match	mnvUserCmdAttrAddr     contained	"?"
syn case match

syn match	mnvUserCmdName	    contained	"\<\u[[:alnum:]]*\>"		skipwhite        nextgroup=mnvUserCmdBlock,mnvUserCmdReplacement
syn match	mnvUserCmdName	    contained	+\<\u[[:alnum:]]*\>\ze\s*\n\s*\%(\\\|["#]\\ \)+	skipwhite skipnl nextgroup=mnvUserCmdBlock,mnvUserCmdReplacement
syn region	mnvUserCmdReplacement contained
      \ start="\S"
      \ start=+^\s*\%(\\\|["#]\\ \)+
      \ skip=+\n\s*\%(\\\|["#]\\ \)+
      \ end="$"
      \ contains=@mnvContinue,@mnvUserCmdList,mnvComFilter
      \ keepend
syn region	mnvUserCmdBlock	    contained
      \ matchgroup=mnvSep
      \ start="{"
      \ end="^\s*\zs}"
      \ contains=@mnvDefBodyList,@mnvUserCmdList

syn match	mnvDelcommand		"\<delc\%[ommand]\>"	skipwhite nextgroup=mnvDelcommandAttr,mnvDelcommandName
syn match	mnvDelcommandAttr	contained	"-buffer\>"		skipwhite nextgroup=mnvDelcommandName
syn match	mnvDelcommandName	contained	"\<\u[[:alnum:]]*\>"

" Lower Priority Comments: after some mnv commands... {{{2
" =======================
if get(g:, "mnvsyn_comment_strings", 1)
  syn region	mnvCommentString	contained oneline start='\S\s\+"'ms=e end='"' extend
endif

if s:mnv9script
  syn cluster mnvComment contains=mnv9Comment
else
  syn cluster mnvComment contains=mnvComment
endif

MNVL syn region	mnvComment
      \ excludenl
      \ start=+"+
      \ skip=+\n\s*\%(\\\|"\\ \)+
      \ end="$"
      \ contains=@mnvCommentGroup,mnvCommentString
      \ extend
MNV9 syn region	mnv9Comment
      \ excludenl
      \ start="\%#=1\s\@1<=#\%({\@!\|{{\)"
      \ skip="\n\s*\%(\\\|#\\ \)"
      \ end="$"
      \ contains=@mnvCommentGroup,mnvCommentString
      \ extend

syn match	mnv9CommentError	contained	"#.*"
syn match	mnvCommentError	contained	+".*+

" Environment Variables: {{{2
" =====================
syn match	mnvEnvvar	"\$\I\i*"
syn match	mnvEnvvar	"\${\I\i*}"

" Strings {{{2
" =======

" In-String Specials:
" Try to catch strings, if nothing else matches (therefore it must precede the others!)
"  mnvEscapeBrace handles ["]  []"] (ie. "s don't terminate string inside [])
" syn region	mnvEscapeBrace	oneline   contained transparent start="[^\\]\(\\\\\)*\[\zs\^\=\]\=" skip="\\\\\|\\\]" end="]"me=e-1
syn match	mnvPatSepErr	contained	"\\)"
syn match	mnvPatSep	contained	"\\|"
syn region	mnvPatSepZone	oneline   contained   matchgroup=mnvPatSepZ start="\\%\=\ze(" skip="\\\\" end="\\)\|[^\\]['"]"	contains=@mnvStringGroup
syn region	mnvPatRegion	contained transparent matchgroup=mnvPatSepR start="\\[z%]\=(" end="\\)"	contains=@mnvSubstList oneline
syn match	mnvNotPatSep	contained	"\\\\"
syn cluster	mnvStringGroup	contains=mnvEscape,mnvEscapeBrace,mnvPatSep,mnvNotPatSep,mnvPatSepErr,mnvPatSepZone,@Spell
syn region	mnvString	oneline keepend	matchgroup=mnvString start=+[^a-zA-Z\\@]"+lc=1 skip=+\\\\\|\\"+ matchgroup=mnvStringEnd end=+"+ nextgroup=mnvSubscript contains=@mnvStringGroup extend
syn region	mnvString	oneline	matchgroup=mnvString start=+[^a-zA-Z\\@]'+lc=1 end=+'+		       nextgroup=mnvSubscript contains=mnvQuoteEscape  extend
"syn region	mnvString	oneline	start="\s/\s*\A"lc=1 skip="\\\\\|\\+" end="/"	contains=@mnvStringGroup  " see tst45.mnv

syn match	mnvEscape	contained	"\\."
" syn match	mnvEscape	contained	+\\[befnrt\"]+
syn match	mnvEscape	contained	"\\\o\{1,3}\|\\[xX]\x\{1,2}\|\\u\x\{1,4}\|\\U\x\{1,8}"
syn match	mnvEscape	contained	"\\<" contains=mnvNotation
syn match	mnvEscape	contained	"\\<\*[^>]*>\=>"
syn match	mnvQuoteEscape	contained	"''"

syn region	mnvString	oneline matchgroup=mnvString start=+$'+ end=+'+ nextgroup=mnvSubscript contains=@mnvStringInterpolation,mnvQuoteEscape  extend
syn region	mnvString	oneline matchgroup=mnvString start=+$"+ end=+"+ nextgroup=mnvSubscript contains=@mnvStringInterpolation,@mnvStringGroup extend
syn region	mnvStringInterpolationExpr  oneline contained matchgroup=mnvSep start=+{+ end=+}+ contains=@mnvExprList
syn match	mnvStringInterpolationBrace contained "{{"
syn match	mnvStringInterpolationBrace contained "}}"
syn cluster	mnvStringInterpolation contains=mnvStringInterpolationExpr,mnvStringInterpolationBrace

syn region	mnvContinueString	contained	matchgroup=mnvContinueString start=+"+  skip=+\n\s*\%(\\\|["#]\\ \)+ end=+"+ end="$" skipwhite nextgroup=mnvSubscript,mnvComment contains=@mnvContinue,@mnvStringGroup
syn region	mnvContinueString	contained	matchgroup=mnvContinueString start=+'+  skip=+\n\s*\%(\\\|["#]\\ \)+ end=+'+ end="$" skipwhite nextgroup=mnvSubscript,mnvComment contains=@mnvContinue,mnvQuoteEscape
syn region	mnvContinueString	contained	matchgroup=mnvContinueString start=+$"+ skip=+\n\s*\%(\\\|["#]\\ \)+ end=+"+ end="$" skipwhite nextgroup=mnvSubscript,mnvComment contains=@mnvContinue,@mnvStringInterpolation,@mnvStringGroup
syn region	mnvContinueString	contained	matchgroup=mnvContinueString start=+$'+ skip=+\n\s*\%(\\\|["#]\\ \)+ end=+'+ end="$" skipwhite nextgroup=mnvSubscript,mnvComment contains=@mnvContinue,@mnvStringInterpolation,mnvQuoteEscape

" Substitutions: {{{2
" =============
syn cluster	mnvSubstList	contains=mnvPatSep,mnvPatRegion,mnvPatSepErr,mnvSubstTwoBS,mnvSubstRange,mnvNotation
syn cluster	mnvSubstRepList	contains=mnvSubstSubstr,mnvSubstTwoBS,mnvNotation
syn cluster	mnvSubstList	add=mnvCollection
syn match	mnvSubst		"^\s*\%(s\%[ubstitute]\|sm\%[agic]\|sno\%[magic]\)\>"		skipwhite nextgroup=mnvSubstPat,mnvSubstFlags,mnvSubstCount
syn match	mnvSubst		"^\s*\%(s\%[ubstitute]\|sm\%[agic]\|sno\%[magic]\)[_#]\@="	skipwhite nextgroup=mnvSubstPat
syn match	mnvSubst		"^\s*\%(s\%[ubstitute]\|sm\%[agic]\|sno\%[magic]\)\%(\d\+\)\@="	skipwhite nextgroup=mnvSubstCount
syn match	mnvSubst1	contained	"\%(s\%[ubstitute]\|sm\%[agic]\>\|sno\%[magic]\)\>"		skipwhite nextgroup=mnvSubstPat,mnvSubstFlags,mnvSubstCount
syn match	mnvSubst1	contained	"\%(s\%[ubstitute]\|sm\%[agic]\>\|sno\%[magic]\)[_#]\@="	skipwhite nextgroup=mnvSubstPat
syn match	mnvSubst1	contained	"\%(s\%[ubstitute]\|sm\%[agic]\>\|sno\%[magic]\)\%(\d\+\)\@="	skipwhite nextgroup=mnvSubstCount
syn match	mnvSubstFlagErr	contained	"[^< \t\r|]\+" contains=mnvSubstFlags
" & and # after :s are always pattern delimiters not flags
syn match	mnvSubstFlags	contained	"[&cegiIlnpr#]\+"	skipwhite nextgroup=mnvSubstCount
syn match	mnvSubstCount	contained	"\d\+\>"
" TODO: MNV9 illegal separators for abbreviated :s form are [-.:], :su\%[...] required
"     : # is allowed but "not recommended" (see :h pattern-delimiter)
syn region	mnvSubstPat	contained	matchgroup=mnvSubstDelim start="\z([!#$%&'()*+,-./:;<=>?@[\]^_`{}~]\)"rs=s+1 skip="\\\\\|\\\z1" end="\z1"re=e-1,me=e-1	contains=@mnvSubstList	nextgroup=mnvSubstRep4	oneline
syn region	mnvSubstRep4	contained	matchgroup=mnvSubstDelim start="\z(.\)" skip="\\\\\|\\\z1" end="\z1" matchgroup=mnvNotation end="<[cC][rR]>"	contains=@mnvSubstRepList	nextgroup=mnvSubstFlagErr	oneline
syn region	mnvCollection	contained 	transparent	start="\\\@<!\[" skip="\\\[" end="\]"	contains=mnvCollClass
syn match	mnvCollClassErr	contained	"\[:.\{-\}:\]"
syn match	mnvCollClass	contained 	transparent	"\%#=1\[:\(alnum\|alpha\|blank\|cntrl\|digit\|graph\|lower\|print\|punct\|space\|upper\|xdigit\|retu\%[rn]\|tab\|escape\|backspace\):\]"
syn match	mnvSubstSubstr	contained	"\\z\=\d"
syn match	mnvSubstTwoBS	contained	"\\\\"

" TODO: flags, unlike count, must follow immediately
"     : distinguish from with MNV9 &var
" syn match	mnvSubst		"^\s*\zs&&\="	skipwhite nextgroup=mnvSubstFlags,mnvSubstCount
" syn match	mnvSubst		"^\s*\zs\~&\="	skipwhite nextgroup=mnvSubstFlags,mnvSubstCount
" syn match	mnvSubst1	contained	"&&\="	skipwhite nextgroup=mnvSubstFlags,mnvSubstCount
" syn match	mnvSubst1	contained	"\~&\="	skipwhite nextgroup=mnvSubstFlags,mnvSubstCount

" two and three letter variants (matched as :s + flags, count may follow immediately)
syn match	mnvSubst		"^\s*\zssc[egiIlnp]\=\a\@!"	skipwhite nextgroup=mnvSubstCount	contains=mnvSubstFlags
syn match	mnvSubst		"^\s*\zssg[ceiIlnpr]\=\a\@!"	skipwhite nextgroup=mnvSubstCount	contains=mnvSubstFlags
syn match	mnvSubst		"^\s*\zssi[ceInpr]\=\a\@!"	skipwhite nextgroup=mnvSubstCount	contains=mnvSubstFlags
syn match	mnvSubst		"^\s*\zssI[ceginplr]\=\a\@!"	skipwhite nextgroup=mnvSubstCount	contains=mnvSubstFlags
syn match	mnvSubst		"^\s*\zssr[cgiInplr]\=\a\@!"	skipwhite nextgroup=mnvSubstCount	contains=mnvSubstFlags

syn match	mnvSubst1	contained	"\<sc[egiIlnp]\=\a\@!"	skipwhite nextgroup=mnvSubstCount	contains=mnvSubstFlags
syn match	mnvSubst1	contained	"\<sg[ceiIlnpr]\=\a\@!"	skipwhite nextgroup=mnvSubstCount	contains=mnvSubstFlags
syn match	mnvSubst1	contained	"\<si[ceInpr]\=\a\@!"	skipwhite nextgroup=mnvSubstCount	contains=mnvSubstFlags
syn match	mnvSubst1	contained	"\<sI[ceginplr]\=\a\@!"	skipwhite nextgroup=mnvSubstCount	contains=mnvSubstFlags
syn match	mnvSubst1	contained	"\<sr[cgiInplr]\=\a\@!"	skipwhite nextgroup=mnvSubstCount	contains=mnvSubstFlags

" Vi compatibility
syn match	mnvSubstDelim	contained	"\\"
syn match	mnvSubstPat	contained	"\\\ze[/?&]" contains=mnvSubstDelim nextgroup=mnvSubstRep4

" Mark: {{{2
" ====
MNVL syn match	mnvExMark	"\<k\%([a-zA-Z0-9]\>\|[[\]<>'`]\)\@="         nextgroup=@mnvMarkArg
MNVL syn match	mnvExMark	"\<k\>"	      	skipwhite nextgroup=@mnvMarkArg
syn match	mnvExMark	"\<mark\>"	      	skipwhite nextgroup=@mnvMarkArg

syn match	mnvMarkArg	contained	"[a-zA-Z]\>\|[[\]<>'`]"	skipwhite nextgroup=mnvCmdSep,mnvComment
syn match	mnvMarkArgError	contained	"["^.(){}0-9]"
syn cluster	mnvMarkArg	contains=mnvMarkArg,mnvMarkArgError

" Marks, Registers, Addresses, Filters: {{{2
syn match	mnvMark	"'[a-zA-Z0-9]\ze\s*$"
syn match	mnvMark	"'[[\]{}()<>'`"^.]\ze\s*$"
syn match	mnvMark	"'[a-zA-Z0-9]\ze[-+,!]"	nextgroup=mnvFilter,mnvMarkNumber,mnvSubst1
syn match	mnvMark	"'[[\]{}()<>'`"^.]\ze[-+,!]"	nextgroup=mnvFilter,mnvMarkNumber,mnvSubst1
syn match	mnvMark	",\zs'[[\]{}()<>'`"^.]"	nextgroup=mnvFilter,mnvMarkNumber,mnvSubst1
syn match	mnvMark	"[!,:]\zs'[a-zA-Z0-9]"	nextgroup=mnvFilter,mnvMarkNumber,mnvSubst1
syn match	mnvMarkNumber	"[-+]\d\+"		contained contains=mnvOper nextgroup=mnvSubst1
syn match	mnvPlainMark contained	"'[a-zA-Z0-9]"
syn match	mnvRange	"[`'][a-zA-Z0-9],[`'][a-zA-Z0-9]"	contains=mnvMark	skipwhite nextgroup=mnvFilter

syn match	mnvRegister	'[^,;[{: \t]\zs"[a-zA-Z0-9.%#:_\-/]\ze[^a-zA-Z_":0-9]'
syn match	mnvRegister	'@"'
syn match	mnvLetRegister	contained	'@["@0-9\-a-zA-Z:.%#=*+~_/]'

syn match	mnvAddress	",\zs[.$]"	skipwhite nextgroup=mnvSubst1
syn match	mnvAddress	"%\ze\a"	skipwhite nextgroup=mnvString,mnvSubst1

syn match	mnvFilter 		"^!!\=[^"]\{-}\(|\|\ze\"\|$\)"	contains=mnvOper,mnvSpecFile
syn match	mnvFilter    contained	"!!\=[^"]\{-}\(|\|\ze\"\|$\)"	contains=mnvOper,mnvSpecFile
syn match	mnvComFilter contained	"|!!\=[^"]\{-}\(|\|\ze\"\|$\)"      contains=mnvOper,mnvSpecFile

" Complex Repeats: (:h complex-repeat) {{{2
" ===============
syn match	mnvCmplxRepeat	'[^a-zA-Z_/\\()]q[0-9a-zA-Z"]\>'lc=1

" NOTE: :* as an alias for :@ is not supported, this is considered a :range,
" see :help cpo-star
syn match	mnvAtArg	contained	+@\@1<=[0-9a-z".=*+:@]+
syn match	mnvAt	+@[0-9a-z".=*+:@]\ze\s*\%($\|[|"#]\)+	skipwhite nextgroup=mnvCmdSep,mnvComment,mnv9Comment contains=mnvAtArg
" MNV9: avoid LHS assignment mismatching of :@["#]
syn match	mnvAt	+@\ze\s*\%($\||\|\s["#]\)+		skipwhite nextgroup=mnvCmdSep,mnvComment,mnv9Comment

" Set command and associated set-options (mnvOptions) with comment {{{2
syn match	mnvSet		"\<\%(setl\%[ocal]\|setg\%[lobal]\|se\%[t]\)\>" skipwhite nextgroup=mnvSetBang,mnvCmdSep,mnvComment,mnvSetArgs
syn region	mnvSetComment	contained	start=+"+ skip=+\n\s*\%(\\\||"\\ \)+ end="$" contains=@mnvCommentGroup,mnvCommentString extend
syn match	mnvSetCmdSep	contained	"|" skipwhite nextgroup=@mnvCmdList,mnvSubst1,@mnvFunc
syn match	mnvSetEscape	contained	"\\\%(\\[|"]\|.\)"
syn match	mnvSetBarEscape	contained	"\\|"
syn match	mnvSetQuoteEscape	contained	+\\"+
syn region	mnvSetArgs	contained
      \ start="\l\|<"
      \ skip=+\n\s*\%(\\\|["#]\\ \)\|^\s*"\\ +
      \ end=+\ze\\\@1<![|"]+
      "\ assume this isn't an escaped char with backslash on the previous line
      \ end=+^\s*\\\ze[|"]+
      \ end="\ze\s#"
      \ end="$"
      \ nextgroup=mnvSetCmdSep,mnvSetComment,mnv9Comment
      \ contains=@mnvContinue,mnvErrSetting,mnvOption,mnvSetAll,mnvSetTermcap
      \ keepend
" TODO: restrict this to valid values?
syn match	mnvOption	contained	"<[^>]\+>"	contains=mnvOption
syn region	mnvSetEqual	contained
      \ matchgroup=mnvOper
      \ start="[=:]\|[-+^]="
      \ skip=+\\\s\|^\s*\%(\\\|["#]\\ \)+
      \ end="\ze\s"
      \ contains=@mnvContinue,mnvCtrlChar,mnvEnvvar,mnvNotation,mnvSetSep,mnvSetEscape,mnvSetBarEscape,mnvSetQuoteEscape
syn match	mnvSetBang	contained	"\a\@1<=!" skipwhite nextgroup=mnvSetAll,mnvSetTermcap
syn keyword	mnvSetAll	contained	all nextgroup=mnvSetMod
syn keyword	mnvSetTermcap	contained	termcap
syn match	mnvSetSep	contained	"[,:]"
syn match	mnvSetMod	contained	"\a\@1<=\%(&mnv\=\|[!&?<]\)"

" Variable Declarations: {{{2
" =====================
MNVL syn keyword	mnvLet	let		skipwhite nextgroup=@mnvSpecialVar,mnvVar,mnvVarList,mnvLetVar
MNVL syn keyword	mnvConst	cons[t]		skipwhite nextgroup=@mnvSpecialVar,mnvVar,mnvVarList,mnvLetVar
syn region	mnvVarList	contained
      \ start="\[" end="]"
      \ skipwhite nextgroup=mnvLetHeredoc
      \ contains=@mnvContinue,@mnvSpecialVar,mnvVar
syn match	mnvLetVar	 contained	"\<\%([bwglstav]:\)\=\h[a-zA-Z0-9#_]*\>\ze\%(\[.*]\)\=\s*=<<"	skipwhite nextgroup=mnvLetVarSubscript,mnvLetHeredoc	contains=mnvVarScope,mnvSubscript
hi link mnvLetVar mnvVar
syn region	mnvLetVarSubscript contained
      \ matchgroup=mnvSubscriptBracket
      \ start="\S\@1<=\["
      \ end="]"
      \ skipwhite nextgroup=mnvLetVarSubscript,mnvLetHeredoc
      \ contains=@mnvExprList

syn keyword	mnvUnlet		unl[et]	skipwhite nextgroup=mnvUnletBang,mnvUnletVars
syn match	mnvUnletBang	contained	"\a\@1<=!"	skipwhite nextgroup=mnvUnletVars
syn region	mnvUnletVars	contained
      \ start="$\I\|\h" skip=+\n\s*\%(\\\|["#]\\ \)\|^\s*["#]\\ + end="$" end=+\ze\s*[|"#]+
      \ skipwhite nextgroup=mnvCmdSep,mnvComment,mnv9Comment
      \ contains=@mnvContinue,mnvEnvvar,mnvVar,mnvMNVVar

" TODO: type error after register or environment variables (strings)
MNVFoldh syn region mnvLetHeredoc	contained
      \ matchgroup=mnvLetHeredocStart
      \ start="\%(^\z(\s*\)\S.*\)\@<==<<\s*trim\%(\s\+\)\@>\z(\L\S*\)"
      \ matchgroup=mnvLetHeredocStop
      \ end="^\z1\=\z2$"
      \ extend
MNVFoldh syn region mnvLetHeredoc	contained
      \ matchgroup=mnvLetHeredocStart
      \ start="=<<\%(\s*\)\@>\z(\L\S*\)"
      \ matchgroup=mnvLetHeredocStop end="^\z1$"
      \ extend
MNVFoldh syn region mnvLetHeredoc	contained
      \ matchgroup=mnvLetHeredocStart
      \ start="\%(^\z(\s*\)\S.*\)\@<==<<\s*\%(trim\s\+eval\|eval\s\+trim\)\%(\s\+\)\@>\z(\L\S*\)"
      \ matchgroup=mnvLetHeredocStop
      \ end="^\z1\=\z2$"
      \ contains=@mnvStringInterpolation
      \ extend
MNVFoldh syn region mnvLetHeredoc	contained
      \ matchgroup=mnvLetHeredocStart
      \ start="=<<\s*eval\%(\s\+\)\@>\z(\L\S*\)"
      \ matchgroup=mnvLetHeredocStop
      \ end="^\z1$"
      \ contains=@mnvStringInterpolation
      \ extend

MNV9 syn keyword	mnv9Const	const	skipwhite nextgroup=mnv9Variable,mnv9VariableList
MNV9 syn keyword	mnv9Final	final	skipwhite nextgroup=mnv9Variable,mnv9VariableList
MNV9 syn keyword	mnv9Var	var	skipwhite nextgroup=mnv9Variable,mnv9VariableList

syn match	mnv9Variable	contained	"\<\h\w*\>"	skipwhite nextgroup=mnv9VariableTypeSep,mnvLetHeredoc,mnvOper
syn region	mnv9VariableList	contained	start="\[" end="]" contains=@mnvContinue,@mnvSpecialVar,mnv9Variable skipwhite nextgroup=mnvLetHeredoc

syn match	mnv9VariableTypeSep	contained	"\S\@1<=:\%(\s\|\n\)\@="		skipwhite nextgroup=@mnv9VariableType
syn keyword	mnv9VariableType		contained	blob bool channel float job number string void	skipwhite nextgroup=mnvLetHeredoc
syn keyword	mnv9VariableTypeAny	contained	any			skipwhite nextgroup=mnvLetHeredoc
syn match	mnv9VariableTypeObject	contained	"\<object<\@="			          nextgroup=mnv9VariableTypeObjectArgs
syn region	mnv9VariableTypeObjectArgs
      \ matchgroup=mnv9VariableTypeObjectBracket
      \ start="<"
      \ end=">"
      \ contains=mnvTypeAny,mnvTypeObject,mnvUserType
      \ oneline
      \ transparent
syn match	mnv9VariableType		contained	"\<\%(func\)\>"			skipwhite nextgroup=mnvLetHeredoc
syn region	mnv9VariableCompoundType	contained
      \ matchgroup=mnv9VariableType
      \ start="\<func("
      \ end=")"
      \ skipwhite nextgroup=mnv9VariableTypeSep,mnvLetHeredoc
      \ contains=@mnv9Continue,@mnv9VariableType
      \ transparent
syn region	mnv9VariableCompoundType	contained
      \ matchgroup=mnv9VariableType
      \ start="\<tuple<"
      \ end=">"
      \ skipwhite nextgroup=mnvLetHeredoc
      \ contains=@mnv9Continue,@mnv9VariableType
      \ transparent
syn region	mnv9VariableCompoundType	contained
      \ matchgroup=mnv9VariableType
      \ start="\<\%(list\|dict\)<"
      \ end=">"
      \ skipwhite nextgroup=mnvLetHeredoc
      \ contains=@mnv9VariableType
      \ oneline
      \ transparent
syn match	mnv9VariableUserType	contained	"\<\%(\h\w*\.\)*\u\w*\>"	skipwhite nextgroup=mnvLetHeredoc

syn cluster mnv9VariableType contains=mnv9VariableType,mnv9VariableTypeAny,mnv9VariableTypeObject,mnv9VariableCompoundType,mnv9VariableUserType

" Lockvar and Unlockvar: {{{2
" =====================
syn keyword	mnvLockvar	lockv[ar]	skipwhite nextgroup=mnvLockvarBang,mnvLockvarDepth,mnvLockvarVars
syn keyword	mnvUnlockvar	unlo[ckvar]	skipwhite nextgroup=mnvLockvarBang,mnvLockvarDepth,mnvLockvarVars
syn match	mnvLockvarBang	contained	"\a\@1<=!"	skipwhite nextgroup=mnvLockvarVars
syn match	mnvLockvarDepth	contained	"\<[0-3]\>"	skipwhite nextgroup=mnvLockvarVars
syn region	mnvLockvarVars	contained
      \ start="\h" skip=+\n\s*\%(\\\|"\\ \)\|^\s*"\\ + end="$" end="\ze[|"]"
      \ nextgroup=mnvCmdSep,mnvComment
      \ contains=@mnvContinue,mnvVar

hi def link mnvLockvar mnvCommand
hi def link mnvUnlockvar mnvCommand
hi def link mnvLockvarBang mnvBang
hi def link mnvLockvarDepth mnvNumber

" For: {{{2
" ===
" handles MNV9 and legacy for now
syn region	mnvFor
      \ matchgroup=mnvCommand
      \ start="\<for\>" end="\<in\>"
      \ skipwhite skipnl nextgroup=@mnvForInContinue,mnv9ForInComment,@mnvExprList
      \ contains=@mnvContinue,mnvVar,mnvVarList,mnv9Variable,mnv9VariableList
      \ transparent

syn match	mnv9ForInComment		contained	"#.*"	skipwhite skipempty nextgroup=mnvForInComment,@mnvExprList

syn match	mnvForInContinue		contained	"^\s*\zs\\"	 skipwhite skipnl nextgroup=@mnvForInContinue,@mnvExprList
syn match         mnvForInContinueComment	contained	'^\s*\zs["#]\\ .*' skipwhite skipnl nextgroup=@mnvForInContinue,@mnvExprList
syn cluster	mnvForInContinue		contains=mnvForInContinue,mnvForInContinueComment

" Abbreviations: {{{2
" =============
" GEN_SYN_MNV: mnvCommand abbrev, START_STR='syn keyword mnvAbb', END_STR='skipwhite nextgroup=mnvMapMod,mnvMapLhs'
" GEN_SYN_MNV: mnvCommand abclear, START_STR='syn keyword mnvAbb', END_STR='skipwhite nextgroup=mnvMapMod'

" Filename Patterns: {{{2
" =================

syn match	mnvWildcardQuestion	contained	"?"
syn match	mnvWildcardStar		contained	"*"

syn match	mnvWildcardBraceComma	contained	","
syn region	mnvWildcardBrace		contained
      \ matchgroup=mnvWildcard
      \ start="{"
      \ end="}"
      \ contains=mnvWildcardEscape,mnvWildcardBrace,mnvWildcardBraceComma,mnvWildcardQuestion,mnvWildcardStar,mnvWildcardBracket
      \ oneline

syn match	mnvWildcardIntervalNumber	contained	"\d\+"
syn match	mnvWildcardInterval	contained	"\\\\\\{\d\+\%(,\d\+\)\=\\}" contains=mnvWildcardIntervalNumber


syn match	mnvWildcardBracket	contained	"\[\%(\^\=]\=\%(\\.\|\[\([:.=]\)[^:.=]\+\1]\|[^][:space:]]\)*\)\@>]"
      \ contains=mnvWildcardBracketStart,mnvWildcardEscape

syn match	mnvWildcardBracketCharacter	contained	"."	nextgroup=@mnvWildcardBracketCharacter,mnvWildcardBracketHyphen,mnvWildcardBracketEnd
syn match	mnvWildcardBracketRightBracket	contained	"]"	nextgroup=@mnvWildcardBracketCharacter,mnvWildcardBracketEnd
syn match	mnvWildcardBracketHyphen	contained	"-]\@!"	nextgroup=@mnvWildcardBracketCharacter
syn match	mnvWildcardBracketEscape	contained	"\\."	nextgroup=@mnvWildcardBracketCharacter,mnvWildcardBracketHyphen,mnvWildcardBracketEnd
syn match	mnvWildcardBracketCharacterClass	contained	"\[:[^:]\+:]"	nextgroup=@mnvWildcardBracketCharacter,mnvWildcardBracketEnd
syn match	mnvWildcardBracketEquivalenceClass	contained	"\[=[^=]\+=]"	nextgroup=@mnvWildcardBracketCharacter,mnvWildcardBracketEnd
syn match	mnvWildcardBracketCollatingSymbol	contained	"\[\.[^.]\+\.]"	nextgroup=@mnvWildcardBracketCharacter,mnvWildcardBracketEnd

syn match	mnvWildcardBracketStart	contained	"\["	nextgroup=mnvWildcardBracketCaret,mnvWildcardBracketRightBracket,@mnvWildcardBracketCharacter
syn match	mnvWildcardBracketCaret	contained	"\^"	nextgroup=@mnvWildcardBracketCharacter,mnvWildcardBracketRightBracket
syn match	mnvWildcardBracketEnd	contained	"]"

syn cluster	mnvWildcardBracketCharacter	contains=mnvWildcardBracketCharacter,mnvWildcardBracketEscape,mnvWildcardBracketCharacterClass,mnvWildcardBracketEquivalenceClass,mnvWildcardBracketCollatingSymbol

syn match	mnvWildcardEscape	contained	"\\."

syn cluster	mnvWildcard		contains=mnvWildcardQuestion,mnvWildcardStar,mnvWildcardBrace,mnvWildcardBracket,mnvWildcardInterval

" Autocmd and Doauto{cmd,all}: {{{2
" ===========================

" TODO: explicitly match the {cmd} arg rather than bailing out to TOP
syn region	mnvAutocmdBlock	contained	matchgroup=mnvSep start="{" end="^\s*\zs}" contains=@mnvDefBodyList

syn match	mnvAutocmdGroup	contained	"\%(\\["|[:space:]]\|[^"|[:space:]]\)\+" skipwhite nextgroup=mnvAutoEvent,mnvAutoEventGlob
syn match	mnvAutocmdBang	contained	"\a\@1<=!"		     skipwhite nextgroup=mnvAutocmdGroup,mnvAutoEvent,mnvAutoEventGlob

" TODO: cleaner handling of | in pattern position
"     : match pattern items in addition to wildcards
syn region	mnvAutocmdPattern	contained
      \ start="|\@!\S"
      \ skip="\\\\\|\\[,[:space:]]"
      \ end="\ze[,[:space:]]"
      \ end="$"
      \ skipwhite nextgroup=mnvAutocmdPatternSep,mnvAutocmdMod,mnvAutocmdBlock,@mnvFunc
      \ contains=mnvEnvvar,@mnvWildcard,mnvAutocmdPatternEscape
syn match	mnvAutocmdBufferPattern	contained	"<buffer\%(=\%(\d\+\|abuf\)\)\=>" skipwhite nextgroup=mnvAutocmdPatternSep,mnvAutocmdMod,mnvAutocmdBlock,@mnvFunc
" trailing pattern separator comma allowed
syn match	mnvAutocmdPatternSep	contained	","	                skipwhite nextgroup=@mnvAutocmdPattern,mnvAutocmdMod,mnvAutocmdBlock
syn match	mnvAutocmdPatternEscape	contained	"\\."
syn cluster	mnvAutocmdPattern		contains=mnvAutocmdPattern,mnvAutocmdBufferPattern

" TODO: MNV9 requires '++' prefix
syn match	mnvAutocmdMod	contained	"\%(++\)\=\<nested\>" skipwhite nextgroup=mnvAutocmdMod,mnvAutocmdBlock
syn match	mnvAutocmdMod	contained	"++once\>"	skipwhite nextgroup=mnvAutocmdMod,mnvAutocmdBlock

" higher priority than mnvAutocmdGroup, assume no group is so named
syn match	mnvAutoEventGlob	contained	"*"	skipwhite nextgroup=@mnvAutocmdPattern
syn match	mnvAutoEventSep	contained	"\a\@1<=,"	nextgroup=mnvAutoEvent
syn match	mnvUserAutoEventSep contained	"\a\@1<=,"	nextgroup=mnvUserAutoEvent

syn match	mnvAutocmd		"\<au\%[tocmd]\>"	skipwhite nextgroup=mnvAutocmdBang,mnvAutocmdGroup,mnvAutoEvent,mnvAutoEventGlob


syn match	mnvDoautocmdMod	contained	"<nomodeline>"		skipwhite nextgroup=mnvAutocmdGroup,mnvAutoEvent
syn match	mnvDoautocmd		"\<do\%[autocmd]\>"	skipwhite nextgroup=mnvDoautocmdMod,mnvAutocmdGroup,mnvAutoEvent
syn match	mnvDoautocmd		"\<doautoa\%[ll]\>"	skipwhite nextgroup=mnvDoautocmdMod,mnvAutocmdGroup,mnvAutoEvent

" Echo And Execute: -- prefer strings! {{{2
" ================
" NOTE: No trailing comments

syn region	mnvEcho
      \ matchgroup=mnvCommand
      \ start="\<ec\%[ho]\>"
      \ start="\<echoe\%[rr]\>"
      \ start="\<echom\%[sg]\>"
      \ start="\<echoc\%[onsole]\>"
      \ start="\<echon\>"
      \ start="\<echow\%[indow]\>"
      \ skip=+\\|\|||\|\n\s*\%(\\\|["#]\\ \)+
      \ end="\ze|"
      \ excludenl end="$"
      \ nextgroup=mnvCmdSep
      \ contains=@mnvContinue,@mnvExprList,mnv9Comment
      \ transparent

syn match	mnvEchohl	"\<echohl\=\>"	skipwhite nextgroup=mnvGroup,mnvHLGroup,mnvEchohlNone
syn case ignore
syn keyword	mnvEchohlNone	contained none
syn case match

syn cluster	mnvEcho	contains=mnvEcho,mnvEchohl

syn region	mnvExecute
      \ matchgroup=mnvCommand
      \ start="\<exe\%[cute]\>"
      \ skip=+\\|\|||\|\n\s*\%(\\\|["#]\\ \)+
      \ end="\ze|"
      \ excludenl end="$"
      \ nextgroup=mnvCmdSep
      \ contains=@mnvContinue,@mnvExprList,mnv9Comment
      \ transparent

syn region	mnvEval
      \ matchgroup=mnvCommand
      \ start="\<ev\%[al]\>"
      \ skip=+\\|\|||\|\n\s*\%(\\\|["#]\\ \)+
      \ end="\ze|"
      \ excludenl end="$"
      \ nextgroup=mnvCmdSep
      \ contains=@mnvContinue,@mnvExprList,mnv9Comment,mnvComment
      \ transparent

" Filter: {{{2
" ======
syn match	mnvExFilter		"\<filt\%[er]\>"	skipwhite nextgroup=mnvExFilterBang,mnvExFilterPattern
syn region	mnvExFilterPattern contained
      \ start="[[:ident:]]"
      \ end="\ze[[:space:]\n]"
      \ skipwhite nextgroup=@mnvCmdList
      \ contains=@mnvSubstList
      \ oneline
syn region	mnvExFilterPattern contained
      \ matchgroup=Delimiter
      \ start="\z([^[:space:][:ident:]|"]\)"
      \ skip="\\\\\|\\\z1"
      \ end="\z1"
      \ skipwhite nextgroup=@mnvCmdList
      \ contains=@mnvSubstList
      \ oneline
syn match	mnvExFilterBang	 contained	"\a\@1<=!"	skipwhite nextgroup=mnvExFilterPattern

" Grep and Make: {{{2
" =============
" | is the command separator, escaped with \| all other backslashes are passed through literally, no tail comments
syn match	mnvGrep		"\<l\=gr\%[ep]\>"		skipwhite nextgroup=mnvGrepBang,mnvGrepArgs,mnvCmdSep
syn match	mnvGrepadd		"\<l\=grepa\%[dd]\>"	skipwhite nextgroup=mnvGrepBang,mnvGrepArgs,mnvCmdSep
syn region	mnvGrepArgs	contained
      \ start="|\@!\S"
      \ skip=+\n\s*\%(\\\|[#"]\\ \)+
      \ matchgroup=mnvCmdSep
      \ end="|"
      \ end="$"
      "\ TODO: include mnvSpecFile
      \ contains=mnvGrepBarEscape
syn match	mnvGrepBarEscape	contained	"\\|"
syn match	mnvGrepBang	contained	"\a\@1<=!"		skipwhite nextgroup=mnvGrepArgs,mnvCmdSep

syn match	mnvMake		"\<l\=make\=\>"		skipwhite nextgroup=mnvMakeBang,mnvMakeArgs,mnvCmdSep
syn region	mnvMakeArgs	contained
      \ start="|\@!\S"
      \ skip=+\n\s*\%(\\\|[#"]\\ \)+
      \ matchgroup=mnvCmdSep
      \ end="|"
      \ end="$"
      "\ TODO: include mnvSpecFile
      \ contains=mnvMakeBarEscape
syn match	mnvMakeBarEscape	contained	"\\|"
syn match	mnvMakeBang	contained	"\a\@1<=!"		skipwhite nextgroup=mnvMakeArgs,mnvCmdSep

" Help*: {{{2
" =====
syn match	mnvHelp	"\<h\%[elp]\>"	skipwhite nextgroup=mnvHelpBang,mnvHelpArg,mnvHelpNextCommand
" TODO: match wildcards, ignoring exceptions?
syn region	mnvHelpArg	contained
      \ start="\S"
      \ matchgroup=Special
      \ end="\%(@\a\a\)\=\ze\s*\%($\|\%x0d\|\%x00\||[^|]\)"
      \ oneline
syn match	mnvHelpNextCommand	contained	"\ze|[^|]"	skipwhite nextgroup=mnvCmdSep
syn match	mnvHelpBang		contained	"\a\@1<=!"	skipwhite nextgroup=mnvHelpArg,mnvHelpNextCommand

syn match	mnvHelpgrep		"\<l\=helpg\%[rep]\>"	skipwhite nextgroup=mnvHelpgrepBang,mnvHelpgrepPattern
syn region	mnvHelpgrepPattern	contained
      \ start="\S"
      \ matchgroup=Special
      \ end="@\a\a\>"
      \ end="$"
      \ contains=@mnvSubstList
      \ oneline

" MNVgrep: {{{2
" =======
syn match	mnvMNVgrep		"\<l\=mnv\%[grep]\>"	skipwhite nextgroup=mnvMNVgrepBang,mnvMNVgrepPattern
syn match	mnvMNVgrepadd		"\<l\=mnvgrepa\%[dd]\>"	skipwhite nextgroup=mnvMNVgrepBang,mnvMNVgrepPattern
syn match	mnvMNVgrepBang	  contained	"\a\@1<=!"		skipwhite nextgroup=mnvMNVgrepPattern
syn region	mnvMNVgrepPattern   contained
      \ start="[[:ident:]]"
      \ end="\ze[[:space:]\n]"
      \ skipwhite nextgroup=mnvMNVgrepFile,mnvCmdSep
      \ contains=@mnvSubstList
      \ oneline
syn region	mnvMNVgrepPattern   contained
      \ matchgroup=Delimiter
      \ start="\z([^[:space:][:ident:]|"]\)"
      \ skip="\\\\\|\\\z1"
      \ end="\z1"
      \ skipwhite nextgroup=mnvMNVgrepFlags,mnvMNVgrepFile,mnvCmdSep
      \ contains=@mnvSubstList
      \ oneline
syn match	mnvMNVgrepEscape	  contained	"\\\%(\\|\|.\)"
syn match	mnvMNVgrepBarEscape contained	"\\|"
syn region	mnvMNVgrepFile	  contained
      \ start="|\@!\S"
      \ matchgroup=mnvCmdSep
      \ end="|"
      \ end="\ze\s"
      \ end="$"
      \ skipwhite nextgroup=mnvMNVgrepFile
      \ contains=mnvSpecFile,mnvMNVgrepEscape,mnvMNVgrepBarEscape
syn match	mnvMNVgrepFlags	  contained	"\<[gjf]\{,3\}\>" skipwhite nextgroup=mnvMNVgrepfile

" Maps: {{{2
" ====
" GEN_SYN_MNV: mnvCommand map, START_STR='syn keyword mnvMap', END_STR='skipwhite nextgroup=mnvMapMod,mnvMapLhs'
syn match	mnvMap	"\<map\>"	skipwhite nextgroup=mnvMapBang,mnvMapMod,mnvMapLhs
syn keyword	mnvMap	no[remap]	skipwhite nextgroup=mnvMapBang,mnvMapMod,mnvMapLhs
" GEN_SYN_MNV: mnvCommand mapclear, START_STR='syn keyword mnvMap', END_STR='skipwhite nextgroup=mnvMapMod'
syn keyword	mnvMap	mapc[lear]	skipwhite nextgroup=mnvMapBang,mnvMapMod
" GEN_SYN_MNV: mnvCommand unmap, START_STR='syn keyword mnvUnmap', END_STR='skipwhite nextgroup=mnvMapMod,mnvMapLhs'
syn keyword	mnvUnmap	unm[ap]	skipwhite nextgroup=mnvMapBang,mnvMapMod,mnvMapLhs

syn match	mnvMapLhs	contained	"\%(.\|\S\)\+"		contains=mnvCtrlChar,mnvNotation,mnvMapLeader skipwhite        nextgroup=mnvMapRhs
syn match	mnvMapLhs	contained	"\%(.\|\S\)\+\ze\s*$"	contains=mnvCtrlChar,mnvNotation,mnvMapLeader skipwhite skipnl nextgroup=mnvMapRhsContinue
syn match	mnvMapBang	contained	"\a\@1<=!"		skipwhite nextgroup=mnvMapMod,mnvMapLhs
syn match	mnvMapMod	contained	"\%#=1<\%(buffer\|expr\|nowait\|script\|silent\|special\|unique\)\+>" contains=mnvMapModKey,mnvMapModErr skipwhite nextgroup=mnvMapMod,mnvMapLhs
syn region	mnvMapRhs	contained
      \ start="\S"
      \ skip=+\\|\|\@1<=|\|\n\s*\%(\\\|["#]\\ \)+
      \ end="\ze|"
      \ end="$"
      \ nextgroup=mnvCmdSep
      \ contains=@mnvContinue,mnvCtrlChar,mnvNotation,mnvMapLeader
syn region	mnvMapRhsContinue	contained
      \ start=+^\s*\%(\\\|["#]\\ \)+
      \ skip=+\\|\|\@1<=|\|\n\s*\%(\\\|["#]\\ \)+
      \ end="\ze|"
      \ end="$"
      \ nextgroup=mnvCmdSep
      \ contains=@mnvContinue,mnvCtrlChar,mnvNotation,mnvMapLeader
syn match	mnvMapLeader	contained	"\%#=1\c<\%(local\)\=leader>"	contains=mnvMapLeaderKey
syn keyword	mnvMapModKey	contained	buffer expr nowait script silent special unique
syn case ignore
syn keyword	mnvMapLeaderKey	contained	leader localleader
syn case match

" Menus: {{{2
" =====
" NOTE: tail comments disallowed
" GEN_SYN_MNV: mnvCommand menu, START_STR='syn keyword mnvMenu', END_STR='skipwhite nextgroup=mnvMenuBang,mnvMenuMod,mnvMenuName,mnvMenuPriority,mnvMenuStatus'
syn keyword mnvMenu popu[p] skipwhite nextgroup=mnvMenuBang,mnvMenuName
syn region	mnvMenuRhs	 contained contains=@mnvContinue,mnvNotation start="|\@!\S"            skip=+\\\\\|\\|\|\n\s*\%(\\\|"\\ \)+ end="$" matchgroup=mnvSep end="|"
syn region	mnvMenuRhsContinue contained contains=@mnvContinue,mnvNotation start=+^\s*\%(\\\|"\\ \)+ skip=+\\\\\|\\|\|\n\s*\%(\\\|"\\ \)+ end="$" matchgroup=mnvSep end="|"
syn match	mnvMenuName	"\.\@!\%(\\\s\|\S\)\+"        contained contains=mnvMenuNotation,mnvNotation skipwhite        nextgroup=mnvCmdSep,mnvMenuRhs
syn match	mnvMenuName	"\.\@!\%(\\\s\|\S\)\+\ze\s*$" contained contains=mnvMenuNotation,mnvNotation skipwhite skipnl nextgroup=mnvCmdSep,mnvMenuRhsContinue
syn match	mnvMenuNotation	"&\a\|&&\|\\\s\|\\\." contained
syn match	mnvMenuPriority	"\<\d\+\%(\.\d\+\)*\>" contained skipwhite nextgroup=mnvMenuName
syn match	mnvMenuMod	"\c<\%(script\|silent\|special\)>" contained skipwhite nextgroup=mnvMenuName,mnvMenuPriority,mnvMenuMod contains=mnvMapModKey,mnvMapModErr
syn keyword	mnvMenuStatus	enable disable nextgroup=mnvMenuName skipwhite
syn match	mnvMenuBang	"\a\@1<=!" contained skipwhite nextgroup=mnvMenuName,mnvMenuMod

syn region	mnvMenutranslate
      \ matchgroup=mnvCommand start="\<menut\%[ranslate]\>"
      \ skip=+\\\\\|\\|\|\n\s*\%(\\\|"\\ \)+
      \ end="$" matchgroup=mnvCmdSep end="|" matchgroup=mnvMenuClear end="\<clear\ze\s*\%(["#|]\|$\)"
      \ contains=@mnvContinue,mnvMenutranslateName keepend transparent
" oneline is sufficient to match the current formatting in runtime/lang/*.mnv
syn match	mnvMenutranslateName "\%(\\\s\|\S\)\+" contained contains=mnvMenuNotation,mnvNotation
syn match	mnvMenutranslateComment +".*+ contained containedin=mnvMenutranslate

" If, While and Return: {{{2
" ====================
syn match	mnvNotFunc	"\%#=1\<\%(if\|el\%[seif]\|retu\%[rn]\|while\)\>"	skipwhite nextgroup=@mnvExprList,mnvNotation
syn match	mnvElse	"\<el\%[se]\>"			skipwhite nextgroup=mnvComment,mnv9Comment
syn match	mnvEndif	"\<en\%[dif]\>"			skipwhite nextgroup=mnvComment,mnv9Comment

" Angle-Bracket Notation: (tnx to Michael Geddes) {{{2
" ======================
syn case ignore
syn match	mnvNotation	contained	"\%#=1\%(\\\|<lt>\)\=<\%([scamd]-\)\{0,4}x\=\%(f\d\{1,2}\|[^ \t:]\|space\|bar\|bslash\|nl\|newline\|lf\|linefeed\|cr\|retu\%[rn]\|enter\|k\=del\%[ete]\|bs\|backspace\|tab\|esc\|csi\|right\|paste\%(start\|end\)\|left\|help\|undo\|k\=insert\|ins\|mouse\|[kz]\=home\|[kz]\=end\|kplus\|kminus\|kdivide\|kmultiply\|kenter\|kpoint\|space\|k\=\%(page\)\=\%(\|down\|up\|k\d\>\)\)>" contains=mnvBracket

syn match	mnvNotation	contained	"\%#=1\%(\\\|<lt>\)\=<\%([scamd2-4]-\)\{0,4}\%(net\|dec\|jsb\|pterm\|urxvt\|sgr\)mouse>"		contains=mnvBracket
syn match	mnvNotation	contained	"\%#=1\%(\\\|<lt>\)\=<\%([scamd2-4]-\)\{0,4}\%(left\|middle\|right\)\%(mouse\|drag\|release\)>"	contains=mnvBracket
syn match	mnvNotation	contained	"\%#=1\%(\\\|<lt>\)\=<\%([scamd2-4]-\)\{0,4}left\%(mouse\|release\)nm>"			contains=mnvBracket
syn match	mnvNotation	contained	"\%#=1\%(\\\|<lt>\)\=<\%([scamd2-4]-\)\{0,4}x[12]\%(mouse\|drag\|release\)>"		contains=mnvBracket
syn match	mnvNotation	contained	"\%#=1\%(\\\|<lt>\)\=<\%([scamd2-4]-\)\{0,4}sgrmouserelease>"			contains=mnvBracket
syn match	mnvNotation	contained	"\%#=1\%(\\\|<lt>\)\=<\%([scamd2-4]-\)\{0,4}mouse\%(up\|down\|move\)>"			contains=mnvBracket
syn match	mnvNotation	contained	"\%#=1\%(\\\|<lt>\)\=<\%([scamd2-4]-\)\{0,4}scrollwheel\%(up\|down\|right\|left\)>"		contains=mnvBracket

syn match	mnvNotation	contained	"\%#=1\%(\\\|<lt>\)\=<\%(sid\|nop\|nul\|lt\|drop\)>"				contains=mnvBracket
syn match	mnvNotation	contained	"\%#=1\%(\\\|<lt>\)\=<\%(snr\|plug\|cursorhold\|ignore\|cmd\|scriptcmd\|focus\%(gained\|lost\)\)>"	contains=mnvBracket
" syn match	mnvNotation	contained	'\%(\\\|<lt>\)\=<C-R>[0-9a-z"%#:.\-=]'he=e-1				contains=mnvBracket
syn match	mnvNotation	contained	'\%#=1\%(\\\|<lt>\)\=<\%([fq]-\)\=\%(line[12]\|count\|bang\|reg\|args\|mods\|lt\)>'		contains=mnvBracket skipwhite nextgroup=mnvSubst1
syn match	mnvNotation	contained	"\%#=1\%(\\\|<lt>\)\=<\%([cas]file\|abuf\|amatch\|cexpr\|cword\|cWORD\|client\|stack\|script\|sf\=lnum\)>"	contains=mnvBracket
syn match	mnvNotation	contained	"\%#=1\%(\\\|<lt>\)\=<\%([scamd]-\)\{0,4}char-\%(\d\+\|0\o\+\|0x\x\+\)>"		contains=mnvBracket

syn match	mnvBracket contained	"[\\<>]"
syn case match

" User Command Highlighting: {{{2
syn match mnvUsrCmd	'^\s*\zs\u\%(\w*\)\@>\%([<.(#[]\|\s\+\%([-+*/%]\=\|\.\.\)=\)\@!'

" MNV user commands

" Compiler plugins
syn match	mnvCompilerSet	"\<CompilerSet\>"	skipwhite nextgroup=mnvSetArgs

" runtime/makemenu.mnv
syn match	mnvSynMenu		"\<SynMenu\>"	skipwhite nextgroup=mnvSynMenuPath
syn match	mnvSynMenuPath	contained	".*\ze:"	nextgroup=mnvSynMenuColon contains=mnvMenuNotation
syn match	mnvSynMenuColon	contained	":"	nextgroup=mnvSynMenuName
syn match	mnvSynMenuName	contained	"\w\+"

" runtime/syntax/syncolor.mnv
syn match	mnvSynColor		"\<SynColor\>"	skipwhite nextgroup=mnvSynColorGroup
syn match	mnvSynColorGroup	contained	"\<\h\w*\>"	skipwhite nextgroup=mnvHiKeyList	contains=mnvGroup
syn match	mnvSynLink		"\<SynLink\>"	skipwhite nextgroup=mnvSynLinkGroup
syn match	mnvSynLinkGroup	contained	"\<\h\w*\>"	skipwhite nextgroup=mnvGroup	contains=mnvGroup

syn cluster mnvExUserCmdList contains=mnvCompilerSet,mnvSynColor,mnvSynLink,mnvSynMenu

" Errors And Warnings: {{{2
" ====================
if !exists("g:mnvsyn_noerror") && !exists("g:mnvsyn_nomnvfunctionerror")
 syn match	mnvFunctionError	contained	"[[:space:]!]\@1<=\<[a-z0-9]\w\{-}\ze\s*("
 syn match	mnvFunctionError	contained	"\%(<[sS][iI][dD]>\|[sg]:\)\d\w\{-}\ze\s*("
 syn match	mnvElseIfErr	"\<else\s\+if\>"
 syn match	mnvBufnrWarn	/\<bufnr\s*(\s*["']\.['"]\s*)/
endif

" Match: {{{2
" =====
syn match	mnvMatch		"\<\%([1-3]\s*\)\=mat\%[ch]\>"	skipwhite nextgroup=mnvMatchGroup,mnvMatchNone contains=mnvCount
syn match	mnvMatchGroup	contained	"[[:alnum:]._-]\+"	skipwhite nextgroup=mnvMatchPattern
syn case ignore
syn keyword	mnvMatchNone	contained	none
syn case match
syn region	mnvMatchPattern	contained
      \ matchgroup=Delimiter
      \ start="\z([!#$%&'()*+,-./:;<=>?@[\]^_`{}~]\)"
      \ skip="\\\\\|\\\z1"
      \ end="\z1"
      \ contains=@mnvSubstList
      \ oneline

" Normal: {{{2
" ======
syn match	mnvNormal		"\<norm\%[al]\>!\=" skipwhite nextgroup=mnvNormalArg contains=mnvBang
syn region	mnvNormalArg	contained	start="\S" skip=+\n\s*\%(\\\|["#]\\ \)+ end="$" contains=@mnvContinue

" Profile: {{{2
" =======
syn match	mnvProfileBang	 contained	"\a\@1<=!"	skipwhite nextgroup=mnvProfileArg
syn keyword	mnvProfileArg	 contained	start	skipwhite nextgroup=mnvProfilePattern
syn keyword	mnvProfileArg	 contained	func	skipwhite nextgroup=mnvProfilePattern
syn keyword	mnvProfileArg	 contained	file	skipwhite nextgroup=mnvProfilePattern
syn keyword	mnvProfileArg	 contained	stop pause	skipwhite nextgroup=mnvCmdSep,@mnvComment
syn keyword	mnvProfileArg	 contained	continue dump	skipwhite nextgroup=mnvCmdSep,@mnvComment
" TODO: match file pattern
syn region	mnvProfilePattern contained
      \ start="\S"
      \ skip=+\\[|"#]+
      \ end="$" end=+\ze\s*[|"#]+
      \ skipwhite nextgroup=mnvCmdSep,mnvComment,mnv9Comment
syn match	mnvProfile	"\<prof\%[ile]\>"	skipwhite nextgroup=mnvProfileBang,mnvProfileArg

syn keyword	mnvProfdelArg	contained	func	skipwhite nextgroup=mnvProfilePattern
syn keyword	mnvProfdelArg	contained	file	skipwhite nextgroup=mnvProfilePattern
syn keyword	mnvProfdelArg	contained	here	skipwhite nextgroup=mnvCmdSep,@mnvComment
syn match	mnvProfdel	"\<profd\%[el]\>" skipwhite nextgroup=mnvProfdelArg

" Prompt{find,repl}: {{{2
" =================
syn region	mnvPromptArg	contained
      \ start="\S"
      \ skip=+\n\s*\%(\\\|["#]\\ \)+
      \ end="$"
      \ contains=@mnvContinue
syn keyword	mnvPrompt	promptf[ind] promptr[epl]	skipwhite nextgroup=mnvPromptArg

" Redir: {{{2
" =====
syn match	mnvRedir		"\<redir\=\>"	skipwhite nextgroup=mnvRedirBang,mnvRedirFileOperator,mnvRedirVariableOperator,mnvRedirRegister,mnvRedirEnd
syn match	mnvRedirBang	       contained	"\a\@1<=!"	skipwhite nextgroup=mnvRedirFileOperator

syn match	mnvRedirFileOperator     contained	">>\="	skipwhite nextgroup=mnvRedirFile
syn region	mnvRedirFile	       contained
      \ start="\S"
      \ matchgroup=Normal
      \ end="\s*$"
      \ end="\s*\ze[|"]"
      \ nextgroup=mnvCmdSep,mnvComment
      \ contains=mnvSpecFile
syn match	mnvRedirRegisterOperator contained	">>\="
syn match	mnvRedirRegister	       contained	"@[a-zA-Z*+"]"	nextgroup=mnvRedirRegisterOperator
syn match	mnvRedirVariableOperator contained	"=>>\="	skipwhite nextgroup=mnvVar
syn keyword	mnvRedirEnd	       contained	END

" Sleep: {{{2
" =====
syn keyword	mnvSleep		sl[eep]		skipwhite nextgroup=mnvSleepBang,mnvSleepArg
syn match	mnvSleepBang	contained	"\a\@1<=!"		skipwhite nextgroup=mnvSleepArg
syn match	mnvSleepArg	contained	"\<\%(\d\+\)\=m\=\>"

" Sort: {{{2
" ====
syn match	mnvSort		"\<sort\=\>"			skipwhite nextgroup=mnvSortBang,@mnvSortOptions,mnvSortPattern,mnvCmdSep
syn match	mnvSortBang	  contained	"\a\@1<=!"			skipwhite nextgroup=@mnvSortOptions,mnvSortPattern,mnvCmdSep
syn match	mnvSortOptionsError contained	"\a\+"
syn match	mnvSortOptions	  contained	"\<[ilur]*[nfxob]\=[ilur]*\>"		skipwhite nextgroup=mnvSortPattern,mnvCmdSep
syn region	mnvSortPattern	  contained
      \ matchgroup=Delimiter
      \ start="\z([^[:space:][:alpha:]|]\)"
      \ skip="\\\\\|\\\z1"
      \ end="\z1"
      \ skipwhite nextgroup=@mnvSortOptions,mnvCmdSep
      \ contains=@mnvSubstList
      \ oneline

syn cluster mnvSortOptions contains=mnvSortOptions,mnvSortOptionsError

" Terminal: {{{2
" ========
syn match	mnvTerminal	"\<ter\%[minal]\>"		skipwhite        nextgroup=mnvTerminalOptions,mnvTerminalCommand
syn match	mnvTerminal	+\<ter\%[minal]\>\ze\s*\n\s*\%(\\\|["#]\\ \)+	skipwhite skipnl nextgroup=mnvTerminalOptions,mnvTerminalCommand,@mnvTerminalContinue

syn match	mnvTerminalContinue	contained	"^\s*\\"       	skipwhite skipnl nextgroup=@mnvTerminalContinue,mnvTerminalOptions,mnvTerminalCommand contains=mnvWhitespace
syn match         mnvTerminalContinueComment	contained	'^\s*["#]\\ .*'	skipwhite skipnl nextgroup=@mnvTerminalContinue,mnvTerminalOptions,mnvTerminalCommand contains=mnvWhitespace
syn cluster	mnvTerminalContinue	contains=mnvTerminalContinue,mnvTerminalContinueComment

syn region	mnvTerminalCommand	contained
      \ start="\S"
      \ skip=+\n\s*\%(\\\|["#]\\ \)+
      \ end="$"
      \ contains=@mnvContinue

syn region	mnvTerminalOptions	contained
      \ start="++"
      \ skip=/\s\+++\|\%(\n\|^\)\s*\%(\\\|["#]\\ \)/
      \ end="\s"
      \ end="$"
      \ skipwhite nextgroup=mnvTerminalCommand
      \ contains=@mnvContinue,mnvTerminalOption
      \ transparent

syn match	mnvTerminalOption	contained	"++\%(\%(no\)\=close\|open\|curwin\|hidden\|norestore\|shell\)\>"
syn match	mnvTerminalOption	contained	"++kill="		nextgroup=mnvTerminalKillOptionArg
syn match	mnvTerminalOption	contained	"++\%(rows\|cols\)="	nextgroup=mnvTerminalSizeOptionArg
syn match	mnvTerminalOption	contained	"++eof="		nextgroup=mnvTerminalEofOptionArg
syn match	mnvTerminalOption	contained	"++type="		nextgroup=mnvTerminalTypeOptionArg
syn match	mnvTerminalOption	contained	"++api="		nextgroup=mnvTerminalApiOptionArg

syn match	mnvTerminalApiOptionArg	contained	"\<\S\+\>"
syn match	mnvTerminalEofOptionArg	contained	"\<\S\+\>"
syn match	mnvTerminalSizeOptionArg	contained	"\<\d\+\>"
syn keyword	mnvTerminalKillOptionArg	contained	term hup quit int kill
syn match	mnvTerminalKillOptionArg	contained	"\<\d\+\>"
syn keyword	mnvTerminalTypeOptionArg	contained	conpty winpty

" Uniq: {{{2
" ====
syn match	mnvUniq		"\<uniq\=\>"	skipwhite nextgroup=mnvUniqBang,@mnvUniqOptions,mnvUniqPattern,mnvCmdSep
syn match	mnvUniqBang	  contained	"\a\@1<=!"	skipwhite nextgroup=@mnvUniqOptions,mnvUniqPattern,mnvCmdSep
syn match	mnvUniqOptionsError contained	"\a\+"
syn match	mnvUniqOptions	  contained	"\<[ilur]*\>"	skipwhite nextgroup=mnvUniqPattern,mnvCmdSep
syn region	mnvUniqPattern	  contained
      \ matchgroup=Delimiter
      \ start="\z([^[:space:][:alpha:]|]\)"
      \ skip="\\\\\|\\\z1"
      \ end="\z1"
      \ skipwhite nextgroup=@mnvUniqOptions,mnvCmdSep
      \ contains=@mnvSubstList
      \ oneline

syn cluster mnvUniqOptions contains=mnvUniqOptions,mnvUniqOptionsError

" Wincmd: {{{2
" ======
syn match	mnvWincmd	"\<winc\%[md]\>"	skipwhite nextgroup=mnvWincmdArg
" TODO: consider extracting this list from the help file
syn match	mnvWincmdArg	contained
      \ "\<[sSvnqojkhlwWtbpPrRxKJHLTfFz]\>\|[\^:=\-+_<>|\]}]\|\<g\s\+[\]}]\|\<g[fFtT]\>"
      \ skipwhite nextgroup=mnvCmdSep,mnvComment,mnv9Comment

" only handles oneline assignments
MNV9 syn match	mnvWincmd	"\s\=\<winc\%[md]\>\ze\s\+=\s*\%([#|]\|$\)"	skipwhite nextgroup=mnvWincmdArg

" Syntax: {{{2
"=======
syn region	mnvGroupList	contained
      \ start="\S"
      \ skip=+\n\s*\%(\\\|["#]\\ \)+
      "\ need to consume the whitespace
      \ end="\s"he=e-1
      \ end="$"
      \ contains=@mnvGroupListContinue,mnvGroupSpecial,mnvGroupListContinueComma
syn keyword	mnvGroupSpecial	contained	ALL	ALLBUT	CONTAINED	TOP
syn match	mnvGroupListComma		contained	","
syn match	mnvGroupListContinueComma	contained	"\s\+,\s*\|,\s\+"	contains=mnvGroupListComma
syn match	mnvGroupListContinueComma	contained	"\s*,\s*\%(\n\s*\%(\\\s\+\|["#]\\ .*\)\)\+"	contains=@mnvGroupListContinue,mnvGroupListComma

syn match	mnvGroupListEquals	contained	"="		skipwhite skipnl nextgroup=mnvGroupListContinueStart,mnvGroupList
" the first continuation line does not terminate the list at whitepace after \
syn match	mnvGroupListContinueStart	contained	"^\%(\s*["#]\\ .*\n\)*\s*\\\s\+"	skipwhite        nextgroup=mnvGroupList contains=@mnvGroupListContinue transparent

syn match	mnvGroupListContinue	contained	"^\s*\\"	skipwhite skipnl nextgroup=@mnvGroupListContinue,mnvGroupListContinueComma contains=mnvWhitespace
syn match	mnvGroupListContinueComment	contained	'^\s*["#]\\ .*'	skipwhite skipnl nextgroup=@mnvGroupListContinue		   contains=mnvWhitespace
syn cluster	mnvGroupListContinue	contains=mnvGroupListContinue,mnvGroupListContinueComment

if !exists("g:mnvsyn_noerror") && !exists("g:mnvsyn_nomnvsynerror")
 syn match	mnvSynError		contained	"\i\+"
endif
syn match	mnvSynContains		contained	"\<contains\>"	skipwhite nextgroup=mnvGroupListEquals
syn match	mnvSynContainedin		contained	"\<containedin\>"	skipwhite nextgroup=mnvGroupListEquals
syn match	mnvSynNextgroup		contained	"\<nextgroup\>"	skipwhite nextgroup=mnvGroupListEquals
if has("conceal")
 " no whitespace allowed after '='
 syn match	mnvSynCchar	contained	"\<cchar="	nextgroup=mnvSynCcharValue
 syn match	mnvSynCcharValue	contained	"\S"
endif

syn match	mnvSyntax	"\<sy\%[ntax]\>"	contains=mnvCommand skipwhite nextgroup=mnvSynType,@mnvComment
syn cluster mnvFunctionBodyList add=mnvSyntax

" Syntax: case {{{2
syn keyword	mnvSynType	contained	case	skipwhite nextgroup=mnvSynCase,mnvSynCaseError
if !exists("g:mnvsyn_noerror") && !exists("g:mnvsyn_nomnvsyncaseerror")
 syn match	mnvSynCaseError	contained	"\i\+"
endif
syn keyword	mnvSynCase	contained	ignore	match

" Syntax: clear {{{2
syn keyword	mnvSynType	contained	clear

" Syntax: cluster {{{2
syn keyword	mnvSynType	contained	cluster	skipwhite nextgroup=mnvClusterName
syn region	mnvClusterName	contained keepend	matchgroup=mnvGroupName start="\h\w*\>" skip=+\\\\\|\\\|\n\s*\%(\\\|"\\ \)+ matchgroup=mnvCmdSep end="$\||" contains=@mnvContinue,mnvGroupAdd,mnvGroupRem,mnvSynContains,mnvSynError
syn match	mnvGroupAdd	contained	"\<add\>"	skipwhite nextgroup=mnvGroupListEquals
syn match	mnvGroupRem	contained	"\<remove\>"	skipwhite nextgroup=mnvGroupListEquals

" Syntax: conceal {{{2
syn match	mnvSynType	contained	"\<conceal\>"	skipwhite nextgroup=mnvSynConceal,mnvSynConcealError
if !exists("g:mnvsyn_noerror") && !exists("g:mnvsyn_nomnvsynconcealerror")
 syn match	mnvSynConcealError contained	"\i\+"
endif
syn keyword	mnvSynConceal	contained	on	off

" Syntax: foldlevel {{{2
syn keyword	mnvSynType	contained	foldlevel	skipwhite nextgroup=mnvSynFoldlevel,mnvSynFoldlevelError
if !exists("g:mnvsyn_noerror") && !exists("g:mnvsyn_nomnvsynfoldlevelerror")
 syn match	mnvSynFoldlevelError	contained	"\i\+"
endif
syn keyword	mnvSynFoldlevel	contained	start	minimum

" Syntax: iskeyword {{{2
syn keyword	mnvSynType		contained	iskeyword	skipwhite nextgroup=mnvSynIskeyword
syn keyword	mnvSynIskeyword		contained	clear
syn match	mnvSynIskeyword		contained	"\S\+"	contains=mnvSynIskeywordSep
syn match	mnvSynIskeywordSep	contained	","

" Syntax: include {{{2
syn keyword	mnvSynType		contained	include	skipwhite nextgroup=mnvSynIncludeCluster
syn match	mnvSynIncludeCluster	contained	"@[_a-zA-Z0-9]\+\>"

" Syntax: keyword {{{2
syn cluster	mnvSynKeyGroup	contains=@mnvContinue,mnvSynCchar,mnvSynNextgroup,mnvSynKeyOpt,mnvSynContainedin
syn keyword	mnvSynType	contained	keyword	skipwhite nextgroup=mnvSynKeyRegion
syn region	mnvSynKeyRegion	contained         keepend	matchgroup=mnvGroupName start="\h\w*\>" skip=+\\\\\|\\|\|\n\s*\%(\\\|"\\ \)+ matchgroup=mnvCmdSep end="|\|$" contains=@mnvSynKeyGroup
syn match	mnvSynKeyOpt	contained	"\%#=1\<\%(conceal\|contained\|transparent\|skipempty\|skipwhite\|skipnl\)\>"

" Syntax: match {{{2
syn cluster	mnvSynMtchGroup	contains=@mnvContinue,mnvSynCchar,mnvSynContains,mnvSynContainedin,mnvSynError,mnvSynMtchOpt,mnvSynNextgroup,mnvSynRegPat,mnvNotation,mnvMtchComment
syn keyword	mnvSynType	contained	match	skipwhite nextgroup=mnvSynMatchRegion
syn region	mnvSynMatchRegion	contained keepend	matchgroup=mnvGroupName start="\h\w*\>" skip=+\\\\\|\\|\|\n\s*\%(\\\|"\\ \)+ matchgroup=mnvCmdSep end="|\|$" contains=@mnvSynMtchGroup
syn match	mnvSynMtchOpt	contained	"\%#=1\<\%(conceal\|transparent\|contained\|excludenl\|keepend\|skipempty\|skipwhite\|display\|extend\|skipnl\|fold\)\>"

" Syntax: off and on {{{2
syn keyword	mnvSynType	contained	enable	list	manual	off	on	reset

" Syntax: region {{{2
syn cluster	mnvSynRegPatGroup	contains=@mnvContinue,mnvPatSep,mnvNotPatSep,mnvSynPatRange,mnvSynNotPatRange,mnvSubstSubstr,mnvPatRegion,mnvPatSepErr,mnvNotation
syn cluster	mnvSynRegGroup	contains=@mnvContinue,mnvSynCchar,mnvSynContains,mnvSynContainedin,mnvSynNextgroup,mnvSynRegOpt,mnvSynReg,mnvSynMtchGrp
syn keyword	mnvSynType	contained	region	skipwhite nextgroup=mnvSynRegion
syn region	mnvSynRegion	contained keepend	matchgroup=mnvGroupName start="\h\w*" skip=+\\\\\|\\|\|\n\s*\%(\\\|"\\ \)+ matchgroup=mnvCmdSep end="|\|$" contains=@mnvSynRegGroup
syn match	mnvSynRegOpt	contained	"\%#=1\<\%(conceal\%(ends\)\=\|transparent\|contained\|excludenl\|skipempty\|skipwhite\|display\|keepend\|oneline\|extend\|skipnl\|fold\)\>"
syn match	mnvSynReg	contained	"\<\%(start\|skip\|end\)="	nextgroup=mnvSynRegPat
syn match	mnvSynMtchGrp	contained	"matchgroup="	nextgroup=mnvGroup,mnvHLGroup
syn region	mnvSynRegPat	contained extend	start="\z([-`~!@#$%^&*_=+;:'",./?]\)"  skip=/\\\\\|\\\z1\|\n\s*\%(\\\|"\\ \)/  end="\z1"  contains=@mnvSynRegPatGroup skipwhite nextgroup=mnvSynPatMod,mnvSynReg
syn match	mnvSynPatMod	contained	"\%#=1\%(hs\|ms\|me\|hs\|he\|rs\|re\)=[se]\%([-+]\d\+\)\="
syn match	mnvSynPatMod	contained	"\%#=1\%(hs\|ms\|me\|hs\|he\|rs\|re\)=[se]\%([-+]\d\+\)\=," nextgroup=mnvSynPatMod
syn match	mnvSynPatMod	contained	"lc=\d\+"
syn match	mnvSynPatMod	contained	"lc=\d\+," nextgroup=mnvSynPatMod
syn region	mnvSynPatRange	contained	start="\["	skip="\\\\\|\\]"   end="]"
syn match	mnvSynNotPatRange	contained	"\\\\\|\\\["
syn match	mnvMtchComment	contained	'"[^"]\+$'

" Syntax: spell {{{2
syn keyword	mnvSynType	contained	spell	skipwhite nextgroup=mnvSynSpell,mnvSynSpellError
if !exists("g:mnvsyn_noerror") && !exists("g:mnvsyn_nomnvsynspellerror")
 syn match	mnvSynSpellError contained	"\i\+"
endif
syn keyword	mnvSynSpell	contained	default	notoplevel	toplevel

" Syntax: sync {{{2
" ============
syn keyword mnvSynType	contained	sync	skipwhite	nextgroup=mnvSyncClear,mnvSyncMatch,mnvSyncError,mnvSyncRegion,mnvSyncArgs
if !exists("g:mnvsyn_noerror") && !exists("g:mnvsyn_nomnvsyncerror")
 syn match	mnvSyncError	contained	"\i\+"
endif

syn region	mnvSyncArgs	contained	start="\S" skip=+\\\\\|\\|\|\n\s*\%(\\\|"\\ \)+ matchgroup=mnvCmdSep end="|\|$" contains=mnvSyncLines,mnvSyncLinebreak,mnvSyncLinecont,mnvSyncFromstart,mnvSyncCcomment

syn keyword	mnvSyncCcomment	contained	ccomment	skipwhite	nextgroup=mnvGroupName
syn keyword	mnvSyncClear	contained	clear	skipwhite	nextgroup=mnvSyncGroupName
syn keyword	mnvSyncFromstart	contained	fromstart
syn keyword	mnvSyncMatch	contained	match	skipwhite	nextgroup=mnvSyncGroupName
syn keyword	mnvSyncRegion	contained	region	skipwhite	nextgroup=mnvSynRegion
syn match	mnvSyncLinebreak	contained	"\<linebreaks="		nextgroup=mnvNumber
syn keyword	mnvSyncLinecont	contained	linecont	skipwhite	nextgroup=mnvSynRegPat
syn match	mnvSyncLines	contained	"\<lines="		nextgroup=mnvNumber
syn match	mnvSyncLines	contained	"\<minlines="		nextgroup=mnvNumber
syn match	mnvSyncLines	contained	"\<maxlines="		nextgroup=mnvNumber
syn match	mnvSyncGroupName	contained	"\<\h\w*\>"	skipwhite	nextgroup=mnvSyncKey
syn match	mnvSyncKey	contained	"\<grouphere\>"	skipwhite	nextgroup=mnvSyncGroup
syn match	mnvSyncKey	contained	"\<groupthere\>"	skipwhite	nextgroup=mnvSyncGroup
syn match	mnvSyncGroup	contained	"\<\h\w*\>"	skipwhite	nextgroup=mnvSynRegPat,mnvSyncNone
syn keyword	mnvSyncNone	contained	NONE

" Syntime: {{{2
" =======
syn keyword	mnvSyntimeArg	contained	on off clear report	skipwhite nextgroup=mnvComment,mnv9Comment,mnvCmdSep
syn keyword	mnvSyntime		synti[me]		skipwhite nextgroup=mnvSyntimeArg
" Additional IsCommand: here by reasons of precedence {{{2
" ====================
syn match	mnvIsCommand	"<Bar>\s*\a\+"	transparent contains=mnvCommand,mnvNotation

" Highlighting: {{{2
" ============
syn cluster	mnvHighlightCluster		contains=mnvHiLink,mnvHiClear,mnvHiKeyList,@mnvComment
if !exists("g:mnvsyn_noerror") && !exists("g:mnvsyn_nomnvhictermerror")
 syn match	mnvHiCtermError	contained	"\D\i*"
endif
syn match	mnvHighlight	"\<hi\%[ghlight]\>"	skipwhite nextgroup=mnvHiBang,@mnvHighlightCluster
syn match	mnvHiBang	contained	"\a\@1<=!"	skipwhite nextgroup=@mnvHighlightCluster

syn case ignore
" Conceal is a generated low-priority match
syn match	mnvHiGroup	contained	"\%(\<Conceal\>\)\@!\i\+"
syn keyword	mnvHiNone	contained	NONE
syn keyword	mnvHiAttrib	contained	none bold inverse italic nocombine reverse standout strikethrough underline undercurl underdashed underdotted underdouble
syn keyword	mnvFgBgAttrib	contained	none bg background fg foreground
syn case match
syn match	mnvHiAttribList	contained	"\i\+"	contains=mnvHiAttrib
syn match	mnvHiAttribList	contained	"\i\+,"he=e-1	contains=mnvHiAttrib nextgroup=mnvHiAttribList
syn case ignore
syn keyword	mnvHiCtermColor	contained	black blue brown cyan darkblue darkcyan darkgray darkgreen darkgrey darkmagenta darkred darkyellow gray green grey grey40 grey50 grey90 lightblue lightcyan lightgray lightgreen lightgrey lightmagenta lightred lightyellow magenta red seagreen white yellow
syn match	mnvHiCtermColor	contained	"\<color\d\{1,3}\>"
syn case match

syn match	mnvHiFontname	contained	"[a-zA-Z\-*]\+"
syn match	mnvHiGuiFontname	contained	"'[a-zA-Z\-* ]\+'"
syn match	mnvHiGuiRgb	contained	"#\x\{6}"

" Highlighting: hi group key=arg ... {{{2
syn cluster	mnvHiCluster contains=mnvGroup,mnvHLGroup,mnvHiGroup,mnvHiNone,mnvHiTerm,mnvHiCTerm,mnvHiStartStop,mnvHiCtermFgBg,mnvHiCtermul,mnvHiCtermfont,mnvHiGui,mnvHiGuiFont,mnvHiGuiFgBg,mnvHiKeyError,mnvNotation,mnvComment,mnv9comment
syn region	mnvHiKeyList	contained 	start="\i\+" skip=+\\\\\|\\|\|\n\s*\%(\\\|"\\ \)+ matchgroup=mnvCmdSep end="|" excludenl end="$" contains=@mnvContinue,@mnvHiCluster
if !exists("g:mnvsyn_noerror") && !exists("g:mnvsyn_mnvhikeyerror")
 syn match	mnvHiKeyError	contained	"\i\+="he=e-1
endif
syn match	mnvHiTerm	contained	"\cterm="he=e-1		nextgroup=mnvHiAttribList
syn match	mnvHiStartStop	contained	"\c\%(start\|stop\)="he=e-1	nextgroup=mnvHiTermcap,mnvOption
syn match	mnvHiCTerm	contained	"\ccterm="he=e-1		nextgroup=mnvHiAttribList
syn match	mnvHiCtermFgBg	contained	"\ccterm[fb]g="he=e-1	nextgroup=mnvHiNmbr,mnvHiCtermColor,mnvFgBgAttrib,mnvHiCtermError
syn match	mnvHiCtermul	contained	"\cctermul="he=e-1	nextgroup=mnvHiNmbr,mnvHiCtermColor,mnvFgBgAttrib,mnvHiCtermError
syn match	mnvHiCtermfont	contained	"\cctermfont="he=e-1	nextgroup=mnvHiNmbr,mnvHiCtermColor,mnvFgBgAttrib,mnvHiCtermError
syn match	mnvHiGui	contained	"\cgui="he=e-1		nextgroup=mnvHiAttribList
syn match	mnvHiGuiFont	contained	"\cfont="he=e-1		nextgroup=mnvHiFontname
syn match	mnvHiGuiFgBg	contained	"\cgui\%([fb]g\|sp\)="he=e-1	nextgroup=mnvHiGroup,mnvHiGuiFontname,mnvHiGuiRgb,mnvFgBgAttrib
syn match	mnvHiTermcap	contained	"\S\+"		contains=mnvNotation
syn match	mnvHiNmbr	contained	'\d\+'

" Highlight: clear {{{2
syn keyword	mnvHiClear	contained	clear	skipwhite nextgroup=mnvGroup,mnvHLGroup,mnvHiGroup

" Highlight: link {{{2
" see tst24 (hi def vs hi) (Jul 06, 2018)
"syn region	mnvHiLink	contained oneline matchgroup=mnvCommand start="\(\<hi\%[ghlight]\s\+\)\@<=\(\(def\%[ault]\s\+\)\=link\>\|\<def\>\)" end="$"	contains=mnvHiGroup,mnvGroup,mnvHLGroup,mnvNotation
" TODO: simplify and allow line continuations --djk
syn region	mnvHiLink	contained matchgroup=Type start="\%(\<hi\%[ghlight]!\=\s\+\)\@<=\%(\%(def\%[ault]\s\+\)\=link\>\|\<def\%[ault]\>\)" skip=+\\\\\|\\|\|\n\s*\%(\\\|"\\ \)+ matchgroup=mnvCmdSep end="|" excludenl end="$" contains=@mnvContinue,@mnvHiCluster

" Control Characters: {{{2
" ==================
syn match	mnvCtrlChar	"[--]"

" Embedded Scripts:  {{{2
" ================
"   perl,ruby	: Benoit Cerrina
"   python,tcl	: Johannes Zellner
"   mzscheme, lua : Charles Campbell

" Allows users to specify the type of embedded script highlighting
" they want:  (lua/mzscheme/perl/python/ruby/tcl support)
"   g:mnvsyn_embed == 0   : don't embed any scripts
"   g:mnvsyn_embed =~# 'l' : embed Lua
"   g:mnvsyn_embed =~# 'm' : embed MzScheme
"   g:mnvsyn_embed =~# 'p' : embed Perl
"   g:mnvsyn_embed =~# 'P' : embed Python
"   g:mnvsyn_embed =~# 'r' : embed Ruby
"   g:mnvsyn_embed =~# 't' : embed Tcl

let s:interfaces = get(g:, "mnvsyn_embed", "lP")

" [-- lua --] {{{3
if s:interfaces =~# 'l'
  syn include @mnvLuaScript syntax/lua.mnv
  unlet b:current_syntax
endif

syn keyword	mnvLua	lua	skipwhite nextgroup=mnvLuaHeredoc,mnvLuaStatement
syn keyword	mnvLua	luado	skipwhite nextgroup=mnvLuaStatement
syn keyword	mnvLua	luafile

syn region	mnvLuaStatement	contained
      \ start="\S"
      \ skip=+\n\s*\%(\\\|["#]\\ \)+
      \ end="$"
      \ contains=@mnvLuaScript,@mnvContinue
MNVFoldl syn region mnvLuaHeredoc	contained
      \ matchgroup=mnvScriptHeredocStart
      \ start=+<<\s*\z(\S\+\)\ze\s*$+
      \ matchgroup=mnvScriptHeredocStop
      \ end=+^\z1$+
      \ contains=@mnvLuaScript
MNVFoldl syn region mnvLuaHeredoc	contained
      \ matchgroup=mnvScriptHeredocStart
      \ start=+<<\ze\s*$+
      \ matchgroup=mnvScriptHeredocStop
      \ end=+^\.$+
      \ contains=@mnvLuaScript
MNVFoldl syn region mnvLuaHeredoc	contained
      \ matchgroup=mnvScriptHeredocStart
      \ start=+\%(^\z(\s*\)\S.*\)\@<=<<\s*trim\s\+\z(\S\+\)\ze\s*$+
      \ matchgroup=mnvScriptHeredocStop
      \ end=+^\z1\=\z2$+
      \ contains=@mnvLuaScript
MNVFoldl syn region mnvLuaHeredoc	contained
      \ matchgroup=mnvScriptHeredocStart
      \ start=+\%(^\z(\s*\)\S.*\)\@<=<<\s*trim\ze\s*$+
      \ matchgroup=mnvScriptHeredocStop
      \ end=+^\z1\=\.$+
      \ contains=@mnvLuaScript

" [-- mzscheme --] {{{3
if s:interfaces =~# 'm'
  let s:iskKeep = &l:isk
  syn include @mnvMzSchemeScript syntax/scheme.mnv
  unlet b:current_syntax
  let &l:isk = s:iskKeep
endif

syn keyword	mnvMzScheme	mz[scheme]	skipwhite nextgroup=mnvMzSchemeHeredoc,mnvMzSchemeStatement
syn keyword	mnvMzScheme	mzf[ile]

syn region	mnvMzSchemeStatement	contained
      \ start="\S"
      \ skip=+\n\s*\%(\\\|["#]\\ \)+
      \ end="$"
      \ contains=@mnvMzSchemeScript,@mnvContinue
MNVFoldm syn region mnvMzSchemeHeredoc	contained
      \ matchgroup=mnvScriptHeredocStart
      \ start=+<<\s*\z(\S\+\)\ze\s*$+
      \ matchgroup=mnvScriptHeredocStop
      \ end=+^\z1$+
      \ contains=@mnvMzSchemeScript
MNVFoldm syn region mnvMzSchemeHeredoc	contained
      \ matchgroup=mnvScriptHeredocStart
      \ start=+<<\ze\s*$+
      \ matchgroup=mnvScriptHeredocStop
      \ end=+^\.$+
      \ contains=@mnvMzSchemeScript
MNVFoldm syn region mnvMzSchemeHeredoc	contained
      \ matchgroup=mnvScriptHeredocStart
      \ start=+\%(^\z(\s*\)\S.*\)\@<=<<\s*trim\s\+\z(\S\+\)\ze\s*$+
      \ matchgroup=mnvScriptHeredocStop
      \ end=+^\z1\=\z2$+
      \ contains=@mnvMzSchemeScript
MNVFoldm syn region mnvMzSchemeHeredoc	contained
      \ matchgroup=mnvScriptHeredocStart
      \ start=+\%(^\z(\s*\)\S.*\)\@<=<<\s*trim\ze\s*$+
      \ matchgroup=mnvScriptHeredocStop
      \ end=+^\z1\=\.$+
      \ contains=@mnvMzSchemeScript

" [-- perl --] {{{3
if s:interfaces =~# 'p'
  syn include @mnvPerlScript syntax/perl.mnv
  unlet b:current_syntax
endif

syn keyword	mnvPerl	pe[rl]	skipwhite nextgroup=mnvPerlHeredoc,mnvPerlStatement
syn keyword	mnvPerl	perld[o]	skipwhite nextgroup=mnvPerlStatement

syn region	mnvPerlStatement	contained
       \ start="\S"
       \ skip=+\n\s*\%(\\\|["#]\\ \)+
       \ end="$"
       \ contains=@mnvPerlScript,@mnvContinue
MNVFoldp syn region mnvPerlHeredoc	contained
       \ matchgroup=mnvScriptHeredocStart
       \ start=+<<\s*\z(\S\+\)\ze\s*$+
       \ matchgroup=mnvScriptHeredocStop
       \ end=+^\z1$+ contains=@mnvPerlScript
MNVFoldp syn region mnvPerlHeredoc	contained
       \ matchgroup=mnvScriptHeredocStart
       \ start=+<<\ze\s*$+	matchgroup=mnvScriptHeredocStop
       \ end=+^\.$+
       \ contains=@mnvPerlScript
MNVFoldp syn region mnvPerlHeredoc	contained
       \ matchgroup=mnvScriptHeredocStart
       \ start=+\%(^\z(\s*\)\S.*\)\@<=<<\s*trim\s\+\z(\S\+\)\ze\s*$+
       \ matchgroup=mnvScriptHeredocStop
       \ end=+^\z1\=\z2$+
       \ contains=@mnvPerlScript
MNVFoldp syn region mnvPerlHeredoc	contained
       \ matchgroup=mnvScriptHeredocStart
       \ start=+\%(^\z(\s*\)\S.*\)\@<=<<\s*trim\ze\s*$+
       \ matchgroup=mnvScriptHeredocStop
       \ end=+^\z1\=\.$+
       \ contains=@mnvPerlScript

" [-- python --] {{{3
if s:interfaces =~# 'P'
  syn include @mnvPythonScript syntax/python2.mnv
  unlet b:current_syntax
endif

syn keyword	mnvPython	py[thon]	skipwhite nextgroup=mnvPythonHeredoc,mnvPythonStatement
syn keyword	mnvPython	pydo	skipwhite nextgroup=mnvPythonStatement
syn keyword	mnvPython	pyfile

syn region	mnvPythonStatement	contained
      \ start="\S"
      \ skip=+\n\s*\%(\\\|["#]\\ \)+
      \ end="$"
      \ contains=@mnvPythonScript,@mnvContinue
MNVFoldP syn region mnvPythonHeredoc	contained
      \ matchgroup=mnvScriptHeredocStart
      \ start=+<<\s*\z(\S\+\)\ze\s*$+
      \ matchgroup=mnvScriptHeredocStop
      \ end=+^\z1$+
      \ contains=@mnvPythonScript
MNVFoldP syn region mnvPythonHeredoc	contained
      \ matchgroup=mnvScriptHeredocStart
      \ start=+<<\ze\s*$+
      \ matchgroup=mnvScriptHeredocStop
      \ end=+^\.$+
      \ contains=@mnvPythonScript
MNVFoldP syn region mnvPythonHeredoc	contained
      \ matchgroup=mnvScriptHeredocStart
      \ start=+\%(^\z(\s*\)\S.*\)\@<=<<\s*trim\s\+\z(\S\+\)\ze\s*$+
      \ matchgroup=mnvScriptHeredocStop
      \ end=+^\z1\=\z2$+
      \ contains=@mnvPythonScript
MNVFoldP syn region mnvPythonHeredoc	contained
      \ matchgroup=mnvScriptHeredocStart
      \ start=+\%(^\z(\s*\)\S.*\)\@<=<<\s*trim\ze\s*$+
      \ matchgroup=mnvScriptHeredocStop
      \ end=+^\z1\=\.$+
      \ contains=@mnvPythonScript

" [-- python3 --] {{{3
if s:interfaces =~# 'P'
  syn include @mnvPython3Script syntax/python.mnv
  unlet b:current_syntax
endif

syn keyword	mnvPython3	python3 py3	skipwhite nextgroup=mnvPython3Heredoc,mnvPython3Statement
syn keyword	mnvPython3	py3do	skipwhite nextgroup=mnvPython3Statement
syn keyword	mnvPython3	py3file

syn region	mnvPython3Statement	contained
      \ start="\S"
      \ skip=+\n\s*\%(\\\|["#]\\ \)+
      \ end="$"
      \ contains=@mnvPython3Script,@mnvContinue
MNVFoldP syn region mnvPython3Heredoc	contained
      \ matchgroup=mnvScriptHeredocStart
      \ start=+<<\s*\z(\S\+\)\ze\s*$+
      \ matchgroup=mnvScriptHeredocStop
      \ end=+^\z1$+
      \ contains=@mnvPython3Script
MNVFoldP syn region mnvPython3Heredoc	contained
      \ matchgroup=mnvScriptHeredocStart
      \ start=+<<\ze\s*$+
      \ matchgroup=mnvScriptHeredocStop
      \ end=+^\.$+
      \ contains=@mnvPython3Script
MNVFoldP syn region mnvPython3Heredoc	contained
      \ matchgroup=mnvScriptHeredocStart
      \ start=+\%(^\z(\s*\)\S.*\)\@<=<<\s*trim\s\+\z(\S\+\)\ze\s*$+
      \ matchgroup=mnvScriptHeredocStop
      \ end=+^\z1\=\z2$+
      \ contains=@mnvPython3Script
MNVFoldP syn region mnvPython3Heredoc	contained
      \ matchgroup=mnvScriptHeredocStart
      \ start=+\%(^\z(\s*\)\S.*\)\@<=<<\s*trim\ze\s*$+
      \ matchgroup=mnvScriptHeredocStop
      \ end=+^\z1\=\.$+
      \ contains=@mnvPython3Script

" [-- pythonx --] {{{3
if s:interfaces =~# 'P'
  if &pyxversion == 2
    syn cluster mnvPythonXScript contains=@mnvPythonScript
  else
    syn cluster mnvPythonXScript contains=@mnvPython3Script
  endif
endif

syn keyword	mnvPythonX	pythonx pyx	skipwhite nextgroup=mnvPythonXHeredoc,mnvPythonXStatement
syn keyword	mnvPythonX	pyxdo	skipwhite nextgroup=mnvPythonXStatement
syn keyword	mnvPythonX	pyxfile

syn region	mnvPythonXStatement	contained
      \ start="\S"
      \ skip=+\n\s*\%(\\\|["#]\\ \)+
      \ end="$"
      \ contains=@mnvPythonXScript,@mnvContinue
MNVFoldP syn region mnvPythonXHeredoc	contained
      \ matchgroup=mnvScriptHeredocStart
      \ start=+<<\s*\z(\S\+\)\ze\s*$+
      \ matchgroup=mnvScriptHeredocStop
      \ end=+^\z1$+
      \ contains=@mnvPythonXScript
MNVFoldP syn region mnvPythonXHeredoc	contained
      \ matchgroup=mnvScriptHeredocStart
      \ start=+<<\ze\s*$+
      \ matchgroup=mnvScriptHeredocStop
      \ end=+^\.$+
      \ contains=@mnvPythonXScript
MNVFoldP syn region mnvPythonXHeredoc	contained
      \ matchgroup=mnvScriptHeredocStart
      \ start=+\%(^\z(\s*\)\S.*\)\@<=<<\s*trim\s\+\z(\S\+\)\ze\s*$+
      \ matchgroup=mnvScriptHeredocStop
      \ end=+^\z1\=\z2$+
      \ contains=@mnvPythonXScript
MNVFoldP syn region mnvPythonXHeredoc	contained
      \ matchgroup=mnvScriptHeredocStart
      \ start=+\%(^\z(\s*\)\S.*\)\@<=<<\s*trim\ze\s*$+
      \ matchgroup=mnvScriptHeredocStop
      \ end=+^\z1\=\.$+
      \ contains=@mnvPythonXScript

" [-- ruby --] {{{3
if s:interfaces =~# 'r'
  syn include @mnvRubyScript syntax/ruby.mnv
  unlet b:current_syntax
endif

syn keyword	mnvRuby	rub[y]	skipwhite nextgroup=mnvRubyHeredoc,mnvRubyStatement
syn keyword	mnvRuby	rubyd[o]	skipwhite nextgroup=mnvRubyStatement
syn keyword	mnvRuby	rubyf[ile]

syn region	mnvRubyStatement	contained
      \ start="\S"
      \ skip=+\n\s*\%(\\\|["#]\\ \)+
      \ end="$"
      \ contains=@mnvRubyScript,@mnvContinue
MNVFoldr syn region mnvRubyHeredoc	contained
      \ matchgroup=mnvScriptHeredocStart
      \ start=+<<\s*\z(\S\+\)\ze\s*$+
      \ matchgroup=mnvScriptHeredocStop
      \ end=+^\z1$+
      \ contains=@mnvRubyScript
MNVFoldr syn region mnvRubyHeredoc	contained
      \ matchgroup=mnvScriptHeredocStart
      \ start=+<<\ze\s*$+	matchgroup=mnvScriptHeredocStop
      \ end=+^\.$+
      \ contains=@mnvRubyScript
MNVFoldr syn region mnvRubyHeredoc	contained
      \ matchgroup=mnvScriptHeredocStart
      \ start=+\%(^\z(\s*\)\S.*\)\@<=<<\s*trim\s\+\z(\S\+\)\ze\s*$+
      \ matchgroup=mnvScriptHeredocStop
      \ end=+^\z1\=\z2$+
      \ contains=@mnvRubyScript
MNVFoldr syn region mnvRubyHeredoc	contained
      \ matchgroup=mnvScriptHeredocStart
      \ start=+\%(^\z(\s*\)\S.*\)\@<=<<\s*trim\ze\s*$+
      \ matchgroup=mnvScriptHeredocStop
      \ end=+^\z1\.$+
      \ contains=@mnvRubyScript

" [-- tcl --] {{{3
if s:interfaces =~# 't'
  syn include @mnvTclScript syntax/tcl.mnv
  unlet b:current_syntax
endif

syn keyword	mnvTcl	tcl	skipwhite nextgroup=mnvTclHeredoc,mnvTclStatement
syn keyword	mnvTcl	tcld[o]	skipwhite nextgroup=mnvTclStatement
syn keyword	mnvTcl	tclf[ile]
syn region	mnvTclStatement	contained
      \ start="\S"
      \ skip=+\n\s*\%(\\\|["#]\\ \)+
      \ end="$"
      \ contains=@mnvTclScript,@mnvContinue
MNVFoldt syn region mnvTclHeredoc	contained
      \ matchgroup=mnvScriptHeredocStart
      \ start=+<<\s*\z(\S\+\)\ze\s*$+
      \ matchgroup=mnvScriptHeredocStop
      \ end=+^\z1$+
      \ contains=@mnvTclScript
MNVFoldt syn region mnvTclHeredoc	contained
      \ matchgroup=mnvScriptHeredocStart
      \ start=+<<\ze\s*$+
      \ matchgroup=mnvScriptHeredocStop
      \ end=+^\.$+
      \ contains=@mnvTclScript
MNVFoldt syn region mnvTclHeredoc	contained
      \ matchgroup=mnvScriptHeredocStart
      \ start=+\%(^\z(\s*\)\S.*\)\@<=<<\s*trim\s\+\z(\S\+\)\ze\s*$+
      \ matchgroup=mnvScriptHeredocStop
      \ end=+^\z1\=\z2$+
      \ contains=@mnvTclScript
MNVFoldt syn region mnvTclHeredoc	contained
      \ matchgroup=mnvScriptHeredocStart
      \ start=+\%(^\z(\s*\)\S.*\)\@<=<<\s*trim\ze\s*$+
      \ matchgroup=mnvScriptHeredocStop
      \ end=+^\z1\=\.$+
      \ contains=@mnvTclScript

unlet s:interfaces
" Function Call Highlighting: {{{2
" (following Gautam Iyer's suggestion)
" ==========================
syn match	mnvFunc	contained	"\<\l\w*\ze\s*("					skipwhite nextgroup=mnvOperParen		contains=mnvFuncName
syn match	mnvUserFunc	contained	"\.\@1<=\l\w*\ze\%(\s*(\|<.*>(\)"				skipwhite nextgroup=mnvOperParen,mnv9TypeArgs
syn match	mnvUserFunc	contained	"\<\%([[:upper:]_]\|\%(\h\w*\.\)\+\h\)\w*\ze\%(\s*(\|<.*>(\)"		skipwhite nextgroup=mnvOperParen,mnv9TypeArgs	contains=mnv9MethodName,mnv9Super,mnv9This
syn match	mnvUserFunc	contained	"\<\%(g:\)\=\%(\h\w*#\)\+\h\w*\ze\%(\s*(\|<.*>(\)"			skipwhite nextgroup=mnvOperParen		contains=mnvVarScope
syn match	mnvUserFunc	contained	"\%(\<[sgbwtlav]:\|<[sS][iI][dD]>\)\%(\h\w*\.\)*\h\w*\ze\%(\s*(\|<.*>(\)"	skipwhite nextgroup=mnvOperParen,mnv9TypeArgs	contains=mnvVarScope,mnvNotation

MNV9 syn match	mnv9UserFunc	"^\s*\zs\%([sgbwtv]:\|<[sS][iI][dD]>\)\=\%(\h\w*[.#]\)*\h\w*\ze[<(]"			skipwhite nextgroup=mnvOperParen,mnv9TypeArgs	contains=mnvVarScope,mnvNotation,mnv9MethodName,mnv9Super,mnv9This
MNV9 syn match	mnv9Func	"^\s*\zs\l\w*\ze("					skipwhite nextgroup=mnvOperParen		contains=mnvFuncName

syn cluster	mnvFunc	contains=mnvFunc,mnvUserFunc
syn cluster	mnv9Func	contains=mnv9Func,mnv9UserFunc

syn region	mnv9TypeArgs	contained
      \ matchgroup=Delimiter
      \ start="<\ze\a"
      \ end=">"
      \ nextgroup=mnvOperParen
      \ contains=@mnvType
      \ oneline

" Beginners - Patterns that involve ^ {{{2
" =========
MNV9 syn region	mnv9LineComment	start=+^[ \t:]*\zs#.*$+ skip=+\n\s*\%(\\\|#\\ \)+ end="$" contains=@mnvCommentGroup,mnvCommentString,mnv9CommentTitle extend
MNVL syn region	mnvLineComment	start=+^[ \t:]*\zs".*$+ skip=+\n\s*\%(\\\|"\\ \)+ end="$" contains=@mnvCommentGroup,mnvCommentString,mnvCommentTitle extend

syn match	mnvCommentTitle	'"\s*\%([sS]:\|\h\w*#\)\=\u\w*\(\s\+\u\w*\)*:'hs=s+1	contained contains=mnvCommentTitleLeader,mnvTodo,@mnvCommentGroup
syn match	mnv9CommentTitle	'#\s*\%([sS]:\|\h\w*#\)\=\%([A-DF-Z]\w*\|E\%(\d\{1,4}\>\)\@!\w*\)\(\s\+\u\w*\)*:'hs=s+1	contained contains=mnv9CommentTitleLeader,mnvTodo,@mnvCommentGroup

" allowed anywhere in the file
if !s:mnv9script
  syn match	mnvShebangError	"^\s*\zs#!.*" display
endif
syn match	mnvShebang	"\%^#!.*" display

syn match	mnvContinue		"^\s*\zs\\"
syn match	mnvContinueComment	'^\s*\zs["#]\\ .*' extend
syn match	mnv9ContinueComment	"^\s*\zs#\\ .*"	 extend
syn cluster	mnvContinue	contains=mnvContinue,mnvContinueComment
syn cluster	mnv9Continue	contains=mnvContinue,mnv9ContinueComment

syn region	mnvString	start='^\s*\\"' end='"' oneline keepend contains=@mnvStringGroup,mnvContinue
syn region	mnvString	start="^\s*\\'" end="'" oneline keepend contains=mnvQuoteEscape,mnvContinue

syn match	mnvCommentTitleLeader	'"\s\+'ms=s+1	contained
syn match	mnv9CommentTitleLeader	'#\s\+'ms=s+1	contained

" Searches And Globals: {{{2
" ====================
MNVL syn match	mnvSearch	'^\s*[/?].*'		contains=mnvSearchDelim
syn match	mnvSearchDelim	'^\s*\zs[/?]\|[/?]$'	contained
MNV9 syn match	mnv9Search	'^\s*:[/?].*'		contains=mnv9SearchDelim
syn match	mnv9SearchDelim	'^\s*\zs:[/?]\|[/?]$'	contained contains=mnvCmdSep
syn region	mnvGlobal	matchgroup=Statement start='\<g\%[lobal]!\=/'  skip='\\.' end='/'	skipwhite nextgroup=mnvSubst1
syn region	mnvGlobal	matchgroup=Statement start='\<v\%[global]!\=/' skip='\\.' end='/'	skipwhite nextgroup=mnvSubst1

" MNV9 script Regions: {{{2
" ==================

if s:mnv9script
  syn cluster mnvLegacyTop	contains=TOP,mnv9LegacyHeader,mnv9Comment,mnv9LineComment
  MNVFoldH syn region mnv9LegacyHeader start="\%^" end="^\ze\s*mnv9s\%[cript]\>" contains=@mnvLegacyTop,mnvComment,mnvLineComment

  syn keyword mnv9MNV9ScriptArg	noclear contained
  syn keyword mnv9MNV9Script	mnv9s[cript] nextgroup=mnv9MNV9ScriptArg skipwhite
endif

" Synchronize (speed) {{{2
"============

exe "syn sync minlines=" .. get(g:, "mnvsyn_minlines", 100)
exe "syn sync maxlines=" .. get(g:, "mnvsyn_maxlines", 200)

syn sync linecont	"^\s\+\\"
syn sync linebreaks=2
syn sync match mnvAugroupSyncA	groupthere NONE	"\<aug\%[roup]\>\s\+[eE][nN][dD]"

" ====================
" Highlighting Settings {{{2
" ====================

if !exists("skip_mnv_syntax_inits")
 if !exists("g:mnvsyn_noerror")
  hi def link mnvBehaveError	mnvError
  hi def link mnvCollClassErr	mnvError
  hi def link mnvErrSetting	mnvError
  hi def link mnvFTError	mnvError
  hi def link mnvFunctionError	mnvError
  hi def link mnvFunc         	mnvError
  hi def link mnv9Func         	mnvError
  hi def link mnvHiAttribList	mnvError
  hi def link mnvHiCtermError	mnvError
  hi def link mnvHiKeyError	mnvError
  hi def link mnvMapModErr	mnvError
  hi def link mnvMarkArgError	mnvError
  hi def link mnvShebangError	mnvError
  hi def link mnvSortOptionsError	Error
  hi def link mnvSubstFlagErr	mnvError
  hi def link mnvSynCaseError	mnvError
  hi def link mnvSyncError	mnvError
  hi def link mnvSynConcealError	mnvError
  hi def link mnvSynError	mnvError
  hi def link mnvSynFoldlevelError	mnvError
  hi def link mnvSynIskeywordError	mnvError
  hi def link mnvSynSpellError	mnvError
  hi def link mnvBufnrWarn	mnvWarn

  hi def link mnv9TypeAliasError	mnvError
 endif

 hi def link mnvAbb	mnvCommand
 hi def link mnvAddress	mnvMark
 hi def link mnvAt	mnvCommand
 hi def link mnvAtArg	Special
 hi def link mnvAugroupBang	mnvBang
 hi def link mnvAugroupError	mnvError
 hi def link mnvAugroupKey	mnvCommand
 hi def link mnvAutocmd	mnvCommand
 hi def link mnvAutocmdBang	mnvBang
 hi def link mnvAutocmdPatternEscape	Special
 hi def link mnvAutoEvent	Type
 hi def link mnvAutoEventGlob	Type
 hi def link mnvAutocmdBufferPattern	Special
 hi def link mnvAutocmdMod	Special
 hi def link mnvAutocmdPatternSep	mnvSep
 hi def link mnvBang	mnvOper
 hi def link mnvBehaveBang	mnvBang
 hi def link mnvBehaveModel	mnvBehave
 hi def link mnvBehave	mnvCommand
 hi def link mnvBracket	Delimiter
 hi def link mnvBreakaddFunc	Special
 hi def link mnvBreakaddFile	Special
 hi def link mnvBreakaddHere	Special
 hi def link mnvBreakaddExpr	Special
 hi def link mnvBreakpointGlob	Special
 hi def link mnvBreakadd	mnvCommand
 hi def link mnvBreakdel	mnvCommand
 hi def link mnvBreaklist	mnvCommand
 hi def link mnvCall	mnvCommand
 hi def link mnvCatch	mnvCommand
 hi def link mnvCd	mnvCommand
 hi def link mnvCdBang	mnvBang
 hi def link mnvCmplxRepeat	SpecialChar
 hi def link mnvCommand	Statement
 hi def link mnvCommandModifier	mnvCommand
 hi def link mnvCommandModifierBang	mnvBang
 hi def link mnvComment	Comment
 hi def link mnvCommentError	mnvError
 hi def link mnvCommentString	mnvString
 hi def link mnvCommentTitle	PreProc
 hi def link mnvCondHL	mnvCommand
 hi def link mnvConst	mnvCommand
 hi def link mnvContinue	Special
 hi def link mnvContinueComment	mnvComment
 hi def link mnvContinueString	mnvString
 hi def link mnvCount	Number
 hi def link mnvCtrlChar	SpecialChar
 hi def link mnvDebug	mnvCommand
 hi def link mnvDebuggreedy	mnvCommand
 hi def link mnvDef	mnvCommand
 hi def link mnvDefBang	mnvBang
 hi def link mnvDefComment	mnv9Comment
 hi def link mnvDefer	mnvCommand
 hi def link mnvDefParam	mnvVar
 hi def link mnvDelcommand	mnvCommand
 hi def link mnvDelcommandAttr	mnvUserCmdAttr
 hi def link mnvDelfunction	mnvCommand
 hi def link mnvDelfunctionBang	mnvBang
 hi def link mnvDoautocmd	mnvCommand
 hi def link mnvDoautocmdMod	Special
 hi def link mnvDoCommand	mnvCommand
 hi def link mnvDoCommandBang	mnvBang
 hi def link mnvEcho	mnvCommand
 hi def link mnvEchohlNone	mnvGroup
 hi def link mnvEchohl	mnvCommand
 hi def link mnvElse	mnvCommand
 hi def link mnvElseIfErr	Error
 hi def link mnvEndfunction	mnvCommand
 hi def link mnvEnddef	mnvCommand
 hi def link mnvEndif	mnvCommand
 hi def link mnvEnvvar	PreProc
 hi def link mnvError	Error
 hi def link mnvEscape	Special
 hi def link mnvEval	mnvCommand
 hi def link mnvExFilter	mnvCommand
 hi def link mnvExFilterBang	mnvBang
 hi def link mnvExMark	mnvCommand
 hi def link mnvFBVar	mnvVar
 hi def link mnvFgBgAttrib	mnvHiAttrib
 hi def link mnvFuncEcho	mnvCommand
 hi def link mnvFor	mnvCommand
 hi def link mnvForInContinue	mnvContinue
 hi def link mnvForInContinueComment	mnvContinueComment
 hi def link mnvFTCmd	mnvCommand
 hi def link mnvFTOption	mnvSynType
 hi def link mnvFunction	mnvCommand
 hi def link mnvFunctionBang	mnvBang
 hi def link mnvFunctionComment	mnvComment
 hi def link mnvFuncName	Function
 hi def link mnvFunctionMod	Special
 hi def link mnvFunctionParam	mnvVar
 hi def link mnvFunctionParamEquals	mnvOper
 hi def link mnvFunctionScope	mnvVarScope
 hi def link mnvFunctionSID	mnvNotation
 hi def link mnvGrep	mnvCommand
 hi def link mnvGrepadd	mnvCommand
 hi def link mnvGrepBang	mnvBang
 hi def link mnvGroup	Type
 hi def link mnvGroupAdd	mnvSynOption
 hi def link mnvGroupListEquals	mnvSynOption
 hi def link mnvGroupListContinue		mnvContinue
 hi def link mnvGroupListContinueComment	mnvContinueComment
 hi def link mnvGroupName	Normal
 hi def link mnvGroupRem	mnvSynOption
 hi def link mnvGroupSpecial	Special
 hi def link mnvHelp	mnvCommand
 hi def link mnvHelpBang	mnvBang
 hi def link mnvHelpgrep	mnvCommand
 hi def link mnvHiAttrib	PreProc
 hi def link mnvHiBang	mnvBang
 hi def link mnvHiClear	Type
 hi def link mnvHiCtermColor	Constant
 hi def link mnvHiCtermFgBg	mnvHiTerm
 hi def link mnvHiCtermfont	mnvHiTerm
 hi def link mnvHiCtermul	mnvHiTerm
 hi def link mnvHiCTerm	mnvHiTerm
 hi def link mnvHighlight	mnvCommand
 hi def link mnvHiGroup	mnvGroupName
 hi def link mnvHiGuiFgBg	mnvHiTerm
 hi def link mnvHiGuiFont	mnvHiTerm
 hi def link mnvHiGuiRgb	mnvNumber
 hi def link mnvHiGui	mnvHiTerm
 hi def link mnvHiNmbr	Number
 hi def link mnvHiNone	mnvGroup
 hi def link mnvHiStartStop	mnvHiTerm
 hi def link mnvHiTerm	Type
 hi def link mnvHLGroup	mnvGroup
 hi def link mnvHistory	mnvCommand
 hi def link mnvHistoryName	Special
 hi def link mnvImport	mnvCommand
 hi def link mnvImportAutoload	Special
 hi def link mnvImportAs	mnvImport
 hi def link mnvInsert	mnvString
 hi def link mnv9KeymapLineComment	mnvKeymapLineComment
 hi def link mnvKeymapLineComment	mnvComment
 hi def link mnvKeymapTailComment	mnvComment
 hi def link mnvLambdaBrace	Delimiter
 hi def link mnvLambdaOperator	mnvOper
 hi def link mnvLanguage	mnvCommand
 hi def link mnvLanguageCategory	Special
 hi def link mnvLanguageNameReserved	Constant
 hi def link mnvLet	mnvCommand
 hi def link mnvLetHeredoc	mnvString
 hi def link mnvLetHeredocStart	Special
 hi def link mnvLetHeredocStop	Special
 hi def link mnvLetRegister	mnvRegister
 hi def link mnvLineComment	mnvComment
 hi def link mnvLua	mnvCommand
 hi def link mnvMake	mnvCommand
 hi def link mnvMakeadd	mnvCommand
 hi def link mnvMakeBang	mnvBang
 hi def link mnvMapBang	mnvBang
 hi def link mnvMapLeader	mnvBracket
 hi def link mnvMapLeaderKey	mnvNotation
 hi def link mnvMapModKey	mnvFunctionSID
 hi def link mnvMapMod	mnvBracket
 hi def link mnvMap	mnvCommand
 hi def link mnvMark	Number
 hi def link mnvMarkNumber	mnvNumber
 hi def link mnvMatch	mnvCommand
 hi def link mnvMatchGroup	mnvGroup
 hi def link mnvMatchNone	mnvGroup
 hi def link mnvMenuBang	mnvBang
 hi def link mnvMenuClear	Special
 hi def link mnvMenuMod	mnvMapMod
 hi def link mnvMenuName	PreProc
 hi def link mnvMenu	mnvCommand
 hi def link mnvMenuNotation	mnvNotation
 hi def link mnvMenuPriority	Number
 hi def link mnvMenuStatus	Special
 hi def link mnvMenutranslateComment	mnvComment
 hi def link mnv9MethodName	mnvFuncName
 hi def link mnvMtchComment	mnvComment
 hi def link mnvMzScheme	mnvCommand
 hi def link mnvNonText	NonText
 hi def link mnvNormal	mnvCommand
 hi def link mnvNotation	Special
 hi def link mnvNotFunc	mnvCommand
 hi def link mnvNotPatSep	mnvString
 hi def link mnvNumber	Number
 hi def link mnvOperError	Error
 hi def link mnvOper	Operator
 hi def link mnvOperContinue	mnvContinue
 hi def link mnvOperContinueComment	mnvContinueComment
 hi def link mnvOption	PreProc
 hi def link mnvOptionVar	Identifier
 hi def link mnvOptionVarName	Identifier
 hi def link mnvParenSep	Delimiter
 hi def link mnvPatSepErr	mnvError
 hi def link mnvPatSepR	mnvPatSep
 hi def link mnvPatSep	SpecialChar
 hi def link mnvPatSepZone	mnvString
 hi def link mnvPatSepZ	mnvPatSep
 hi def link mnvPattern	Type
 hi def link mnvPerl	mnvCommand
 hi def link mnvPlainMark	mnvMark
 hi def link mnvProfile	mnvCommand
 hi def link mnvProfileArg	mnvSpecial
 hi def link mnvProfileBang	mnvBang
 hi def link mnvProfdel	mnvCommand
 hi def link mnvProfdelArg	mnvSpecial
 hi def link mnvPrompt	mnvCommand
 hi def link mnvPython	mnvCommand
 hi def link mnvPython3	mnvCommand
 hi def link mnvPythonX	mnvCommand
 hi def link mnvQuoteEscape	mnvEscape
 hi def link mnvRedir	mnvCommand
 hi def link mnvRedirBang	mnvBang
 hi def link mnvRedirFileOperator	mnvOper
 hi def link mnvRedirRegisterOperator	mnvOper
 hi def link mnvRedirVariableOperator	mnvOper
 hi def link mnvRedirEnd	Special
 hi def link mnvRedirRegister	mnvRegister
 hi def link mnvRegister	SpecialChar
 hi def link mnvRuby	mnvCommand
 hi def link mnvScriptDelim	Comment
 hi def link mnvScriptHeredocStart	mnvLetHeredocStart
 hi def link mnvScriptHeredocStop	mnvLetHeredocStop
 hi def link mnvSearch	mnvString
 hi def link mnvSearchDelim	Delimiter
 hi def link mnvSep	Delimiter
 hi def link mnvSet	mnvCommand
 hi def link mnvSetAll	mnvOption
 hi def link mnvSetBang	mnvBang
 hi def link mnvSetComment	mnvComment
 hi def link mnvSetMod	mnvOption
 hi def link mnvSetSep	mnvSep
 hi def link mnvSetTermcap	mnvOption
 hi def link mnvShebang	PreProc
 hi def link mnvSleep	mnvCommand
 hi def link mnvSleepArg	Constant
 hi def link mnvSleepBang	mnvBang
 hi def link mnvSort	mnvCommand
 hi def link mnvSortBang	mnvBang
 hi def link mnvSortOptions	Special
 hi def link mnvSpecFile	Identifier
 hi def link mnvSpecFileMod	mnvSpecFile
 hi def link mnvSpecial	Type
 hi def link mnvStringCont	mnvString
 hi def link mnvString	String
 hi def link mnvStringEnd	mnvString
 hi def link mnvStringInterpolationBrace	mnvEscape
 hi def link mnvSubst1	mnvSubst
 hi def link mnvSubstCount	Number
 hi def link mnvSubstDelim	Delimiter
 hi def link mnvSubstFlags	Special
 hi def link mnvSubstSubstr	SpecialChar
 hi def link mnvSubstTwoBS	mnvString
 hi def link mnvSubst	mnvCommand
 hi def link mnvSynCase	Type
 hi def link mnvSyncCcomment	Type
 hi def link mnvSynCchar	mnvSynOption
 hi def link mnvSynCcharValue	Character
 hi def link mnvSyncClear	Type
 hi def link mnvSyncFromstart	Type
 hi def link mnvSyncGroup	mnvGroupName
 hi def link mnvSyncGroupName	mnvGroupName
 hi def link mnvSyncKey	Type
 hi def link mnvSyncLinebreak	Type
 hi def link mnvSyncLinecont	Type
 hi def link mnvSyncLines	Type
 hi def link mnvSyncMatch	Type
 hi def link mnvSyncNone	Type
 hi def link mnvSynConceal	Type
 hi def link mnvSynContains	mnvSynOption
 hi def link mnvSyncRegion	Type
 hi def link mnvSynFoldlevel	Type
 hi def link mnvSynIskeyword	Type
 hi def link mnvSynIskeywordSep	Delimiter
 hi def link mnvSynContainedin	mnvSynContains
 hi def link mnvSynKeyOpt	mnvSynOption
 hi def link mnvSynMtchGrp	mnvSynOption
 hi def link mnvSynMtchOpt	mnvSynOption
 hi def link mnvSynNextgroup	mnvSynOption
 hi def link mnvSynNotPatRange	mnvSynRegPat
 hi def link mnvSynOption	Special
 hi def link mnvSynPatRange	mnvString
 hi def link mnvSynReg	Type
 hi def link mnvSynRegOpt	mnvSynOption
 hi def link mnvSynRegPat	mnvString
 hi def link mnvSynSpell	Type
 hi def link mnvSyntax	mnvCommand
 hi def link mnvSynType	mnvSpecial
 hi def link mnvSyntime	mnvCommand
 hi def link mnvSyntimeArg	mnvSpecial
 hi def link mnvTcl	mnvCommand
 hi def link mnvTerminal	mnvCommand
 hi def link mnvTerminalContinue	mnvContinue
 hi def link mnvTerminalContinueComment	mnvContinueComment
 hi def link mnvTerminalOption		mnvSpecial
 hi def link mnvTerminalKillOptionArg	Constant
 hi def link mnvTerminalSizeOptionArg	Constant
 hi def link mnvTerminalTypeOptionArg	Constant
 hi def link mnvThrow	mnvCommand
 hi def link mnvTodo	Todo
 hi def link mnvType	Type
 hi def link mnvTypeAny	mnvType
 hi def link mnvTypeObject	mnvType
 hi def link mnvTypeObjectBracket	mnvTypeObject
 hi def link mnvUniq	mnvCommand
 hi def link mnvUniqBang	mnvBang
 hi def link mnvUniqOptions	Special
 hi def link mnvUnlet	mnvCommand
 hi def link mnvUnletBang	mnvBang
 hi def link mnvUnmap	mnvMap
 hi def link mnvUserCmd	mnvCommand
 hi def link mnvUserCmdAttrAddr	mnvSpecial
 hi def link mnvUserCmdAttrComplete	mnvSpecial
 hi def link mnvUserCmdAttrCompleteFunc	mnvVar
 hi def link mnvUserCmdAttrNargs	mnvSpecial
 hi def link mnvUserCmdAttrRange	mnvSpecial
 hi def link mnvUserCmdAttrKey	mnvUserCmdAttr
 hi def link mnvUserCmdAttr	Special
 hi def link mnvUserCmdAttrError	Error
 hi def link mnvUserCmdError	Error
 hi def link mnvUserCmdKey	mnvCommand
 hi def link mnvUserFunc	Normal
 hi def link mnvVar	Normal
 hi def link mnvVarScope	Identifier
 hi def link mnvMNVgrep	mnvCommand
 hi def link mnvMNVgrepadd	mnvCommand
 hi def link mnvMNVgrepBang	mnvBang
 hi def link mnvMNVgrepFlags	Special
 hi def link mnvMNVVar	Identifier
 hi def link mnvMNVVarName	Identifier
 hi def link mnvWarn	WarningMsg
 hi def link mnvWildcard	Special
 hi def link mnvWildcardBraceComma	mnvWildcard
 hi def link mnvWildcardBracket	mnvWildcard
 hi def link mnvWildcardBracketCaret	mnvWildcard
 hi def link mnvWildcardBracketCharacter	Normal
 hi def link mnvWildcardBracketCharacter	Normal
 hi def link mnvWildcardBracketCharacterClass	mnvWildCard
 hi def link mnvWildcardBracketCollatingSymbol	mnvWildCard
 hi def link mnvWildcardBracketEnd		mnvWildcard
 hi def link mnvWildcardBracketEquivalenceClass	mnvWildCard
 hi def link mnvWildcardBracketEscape	mnvWildcard
 hi def link mnvWildcardBracketHyphen	mnvWildcard
 hi def link mnvWildcardBracketRightBracket	mnvWildcardBracketCharacter
 hi def link mnvWildcardBracketStart	mnvWildcard
 hi def link mnvWildcardEscape	mnvWildcard
 hi def link mnvWildcardInterval	mnvWildcard
 hi def link mnvWildcardQuestion	mnvWildcard
 hi def link mnvWildcardStar	mnvWildcard
 hi def link mnvWinCmd	mnvCommand

 hi def link mnv9Abstract	mnvCommand
 hi def link mnv9Boolean	Boolean
 hi def link mnv9Class	mnvCommand
 hi def link mnv9Comment	Comment
 hi def link mnv9CommentError	mnvError
 hi def link mnv9CommentTitle	PreProc
 hi def link mnv9ConstructorDefParam	mnvVar
 hi def link mnv9Const	mnvCommand
 hi def link mnv9ContinueComment	mnvContinueComment
 hi def link mnv9Enum	mnvCommand
 hi def link mnv9EnumImplementedInterfaceComment	mnv9Comment
 hi def link mnv9EnumImplements	mnv9Implements
 hi def link mnv9EnumNameComment	mnv9Comment
 hi def link mnv9EnumNameContinue	mnvContinue
 hi def link mnv9EnumNameContinueComment	mnv9Comment
 hi def link mnv9EnumValueListCommaComment	mnv9Comment
 hi def link mnv9Export	mnvCommand
 hi def link mnv9Extends	Keyword
 hi def link mnv9Final	mnvCommand
 hi def link mnv9For	mnvCommand
 hi def link mnv9ForInComment	mnv9Comment
 hi def link mnv9Implements	Keyword
 hi def link mnv9AbstractDef	mnvCommand
 hi def link mnv9Interface	mnvCommand
 hi def link mnv9LambdaOperator	mnvOper
 hi def link mnv9LambdaOperatorComment	mnv9Comment
 hi def link mnv9LambdaParen	mnvParenSep
 hi def link mnv9LhsRegister	mnvLetRegister
 hi def link mnv9LhsVariable	mnvVar
 hi def link mnv9LineComment	mnvComment
 hi def link mnv9MethodDef	mnvCommand
 hi def link mnv9MethodDefComment	mnvDefComment
 hi def link mnv9MethodNameError	mnvFunctionError
 hi def link mnv9Null	Constant
 hi def link mnv9Public	mnvCommand
 hi def link mnv9Search	mnvString
 hi def link mnv9SearchDelim	Delimiter
 hi def link mnv9Static	mnvCommand
 hi def link mnv9Super	Identifier
 hi def link mnv9This	Identifier
 hi def link mnv9Type	mnvCommand
 hi def link mnv9TypeEquals	mnvOper
 hi def link mnv9Variable	mnvVar
 hi def link mnv9VariableType	mnvType
 hi def link mnv9VariableTypeAny	mnvTypeAny
 hi def link mnv9VariableTypeObject	mnvTypeObject
 hi def link mnv9VariableTypeObjectBracket	mnvTypeObjectBracket
 hi def link mnv9Var	mnvCommand
 hi def link mnv9MNV9ScriptArg	Special
 hi def link mnv9MNV9Script	mnvCommand

 hi def link mnvCompilerSet	mnvCommand
 hi def link mnvSynColor mnvCommand
 hi def link mnvSynLink mnvCommand
 hi def link mnvSynMenu	mnvCommand
 hi def link mnvSynMenuPath	mnvMenuName
endif

" Current Syntax Variable: {{{2
let b:current_syntax = "mnv"

" ---------------------------------------------------------------------
" Cleanup: {{{1
delc MNV9
delc MNVL
delc MNVFolda
delc MNVFoldc
delc MNVFolde
delc MNVFoldf
delc MNVFoldh
delc MNVFoldH
delc MNVFoldi
delc MNVFoldl
delc MNVFoldm
delc MNVFoldp
delc MNVFoldP
delc MNVFoldr
delc MNVFoldt
let &cpo = s:keepcpo
unlet s:keepcpo s:mnv9script
" mnv:ts=18 fdm=marker ft=mnv
