|
| 1 | +syntax region jsFlowDefinition contained start=/:/ end=/\%(\s*[,=;)\n]\)\@=/ contains=@jsFlowCluster containedin=jsParen |
| 2 | +syntax region jsFlowArgumentDef contained start=/:/ end=/\%(\s*[,)]\|=>\@!\)\@=/ contains=@jsFlowCluster |
| 3 | +syntax region jsFlowArray contained matchgroup=jsFlowNoise start=/\[/ end=/\]/ contains=@jsFlowCluster,jsComment fold |
| 4 | +syntax region jsFlowObject contained matchgroup=jsFlowNoise start=/{/ end=/}/ contains=@jsFlowCluster,jsComment fold |
| 5 | +syntax region jsFlowExactObject contained matchgroup=jsFlowNoise start=/{|/ end=/|}/ contains=@jsFlowCluster,jsComment fold |
| 6 | +syntax region jsFlowParens contained matchgroup=jsFlowNoise start=/(/ end=/)/ contains=@jsFlowCluster nextgroup=jsFlowArrow skipwhite keepend extend fold |
| 7 | +syntax match jsFlowNoise contained /[:;,<>]/ |
| 8 | +syntax keyword jsFlowType contained boolean number string null void any mixed JSON array Function object array bool class |
| 9 | +syntax keyword jsFlowTypeof contained typeof skipempty skipwhite nextgroup=jsFlowTypeCustom,jsFlowType |
| 10 | +syntax match jsFlowTypeCustom contained /[0-9a-zA-Z_.]*/ skipwhite skipempty nextgroup=jsFlowGeneric |
| 11 | +syntax region jsFlowGeneric matchgroup=jsFlowNoise start=/\k\@<=</ end=/>/ contains=@jsFlowCluster containedin=@jsExpression,jsFlowDeclareBlock |
| 12 | +syntax region jsFlowGeneric contained matchgroup=jsFlowNoise start=/</ end=/>(\@=/ oneline contains=@jsFlowCluster containedin=@jsExpression,jsFlowDeclareBlock |
| 13 | +syntax region jsFlowObjectGeneric contained matchgroup=jsFlowNoise start=/\k\@<=</ end=/>/ contains=@jsFlowCluster nextgroup=jsFuncArgs |
| 14 | +syntax match jsFlowArrow contained /=>/ skipwhite skipempty nextgroup=jsFlowType,jsFlowTypeCustom,jsFlowParens |
| 15 | +syntax match jsFlowObjectKey contained /[0-9a-zA-Z_$?]*\(\s*:\)\@=/ contains=jsFunctionKey,jsFlowMaybe skipwhite skipempty nextgroup=jsObjectValue containedin=jsObject |
| 16 | +syntax match jsFlowOrOperator contained /|/ skipwhite skipempty nextgroup=@jsFlowCluster |
| 17 | +syntax keyword jsFlowImportType contained type typeof skipwhite skipempty nextgroup=jsModuleAsterisk,jsModuleKeyword,jsModuleGroup |
| 18 | +syntax match jsFlowWildcard contained /*/ |
| 19 | + |
| 20 | +syntax match jsFlowReturn contained /:\s*/ contains=jsFlowNoise skipwhite skipempty nextgroup=@jsFlowReturnCluster,jsFlowArrow,jsFlowReturnParens |
| 21 | +syntax region jsFlowReturnObject contained matchgroup=jsFlowNoise start=/{/ end=/}/ contains=@jsFlowCluster skipwhite skipempty nextgroup=jsFuncBlock,jsFlowReturnOrOp extend fold |
| 22 | +syntax region jsFlowReturnArray contained matchgroup=jsFlowNoise start=/\[/ end=/\]/ contains=@jsFlowCluster skipwhite skipempty nextgroup=jsFuncBlock,jsFlowReturnOrOp fold |
| 23 | +syntax region jsFlowReturnParens contained matchgroup=jsFlowNoise start=/(/ end=/)/ contains=@jsFlowCluster skipwhite skipempty nextgroup=jsFuncBlock,jsFlowReturnOrOp,jsFlowReturnArrow fold |
| 24 | +syntax match jsFlowReturnArrow contained /=>/ skipwhite skipempty nextgroup=@jsFlowReturnCluster |
| 25 | +syntax match jsFlowReturnKeyword contained /\k\+/ contains=jsFlowType,jsFlowTypeCustom skipwhite skipempty nextgroup=jsFlowReturnGroup,jsFuncBlock,jsFlowReturnOrOp,jsFlowReturnArray |
| 26 | +syntax match jsFlowReturnMaybe contained /?/ skipwhite skipempty nextgroup=jsFlowReturnKeyword,jsFlowReturnObject,jsFlowReturnParens |
| 27 | +syntax region jsFlowReturnGroup contained matchgroup=jsFlowNoise start=/</ end=/>/ contains=@jsFlowCluster skipwhite skipempty nextgroup=jsFuncBlock,jsFlowReturnOrOp |
| 28 | +syntax match jsFlowReturnOrOp contained /\s*|\s*/ skipwhite skipempty nextgroup=@jsFlowReturnCluster |
| 29 | +syntax match jsFlowWildcardReturn contained /*/ skipwhite skipempty nextgroup=jsFuncBlock |
| 30 | +syntax keyword jsFlowTypeofReturn contained typeof skipempty skipwhite nextgroup=@jsFlowReturnCluster |
| 31 | + |
| 32 | +syntax region jsFlowFunctionGroup contained matchgroup=jsFlowNoise start=/</ end=/>/ contains=@jsFlowCluster skipwhite skipempty nextgroup=jsFuncArgs |
| 33 | +syntax region jsFlowClassGroup contained matchgroup=jsFlowNoise start=/</ end=/>/ contains=@jsFlowCluster skipwhite skipempty nextgroup=jsClassBlock |
| 34 | +syntax region jsFlowClassFunctionGroup contained matchgroup=jsFlowNoise start=/</ end=/>/ contains=@jsFlowCluster skipwhite skipempty nextgroup=jsFuncArgs |
| 35 | +syntax match jsFlowObjectFuncName contained /\<\K\k*<\@=/ skipwhite skipempty nextgroup=jsFlowObjectGeneric containedin=jsObject |
| 36 | + |
| 37 | +syntax region jsFlowTypeStatement start=/\(opaque\s\+\)\?type\%(\s\+\k\)\@=/ end=/=\@=/ contains=jsFlowTypeOperator oneline skipwhite skipempty nextgroup=jsFlowTypeValue keepend |
| 38 | +syntax region jsFlowTypeValue contained matchgroup=jsFlowNoise start=/=/ end=/\%(;\|\n\%(\s*|\)\@!\)/ contains=@jsFlowCluster,jsFlowGeneric,jsFlowMaybe |
| 39 | +syntax match jsFlowTypeOperator contained /=/ containedin=jsFlowTypeValue |
| 40 | +syntax match jsFlowTypeOperator contained /=/ |
| 41 | +syntax keyword jsFlowTypeKeyword contained type |
| 42 | + |
| 43 | +syntax keyword jsFlowDeclare declare skipwhite skipempty nextgroup=jsFlowTypeStatement,jsClassDefinition,jsStorageClass,jsFlowModule,jsFlowInterface |
| 44 | +syntax match jsFlowClassProperty contained /\<[0-9a-zA-Z_$]*\>:\@=/ skipwhite skipempty nextgroup=jsFlowClassDef containedin=jsClassBlock |
| 45 | +syntax region jsFlowClassDef contained start=/:/ end=/\%(\s*[,=;)\n]\)\@=/ contains=@jsFlowCluster skipwhite skipempty nextgroup=jsClassValue |
| 46 | + |
| 47 | +syntax region jsFlowModule contained start=/module/ end=/\%({\|:\)\@=/ skipempty skipwhite nextgroup=jsFlowDeclareBlock contains=jsString |
| 48 | +syntax region jsFlowInterface contained start=/interface/ end=/{\@=/ skipempty skipwhite nextgroup=jsFlowInterfaceBlock contains=@jsFlowCluster |
| 49 | +syntax region jsFlowDeclareBlock contained matchgroup=jsFlowNoise start=/{/ end=/}/ contains=jsFlowDeclare,jsFlowNoise fold |
| 50 | + |
| 51 | +syntax match jsFlowMaybe contained /?/ |
| 52 | +syntax region jsFlowInterfaceBlock contained matchgroup=jsFlowNoise start=/{/ end=/}/ contains=jsObjectKey,jsObjectKeyString,jsObjectKeyComputed,jsObjectSeparator,jsObjectFuncName,jsFlowObjectFuncName,jsObjectMethodType,jsGenerator,jsComment,jsObjectStringKey,jsSpreadExpression,jsFlowNoise,jsFlowParens,jsFlowGeneric keepend fold |
| 53 | + |
| 54 | +syntax region jsFlowParenAnnotation contained start=/:/ end=/[,=)]\@=/ containedin=jsParen contains=@jsFlowCluster |
| 55 | + |
| 56 | +syntax cluster jsFlowReturnCluster contains=jsFlowNoise,jsFlowReturnObject,jsFlowReturnArray,jsFlowReturnKeyword,jsFlowReturnGroup,jsFlowReturnMaybe,jsFlowReturnOrOp,jsFlowWildcardReturn,jsFlowReturnArrow,jsFlowTypeofReturn |
| 57 | +syntax cluster jsFlowCluster contains=jsFlowArray,jsFlowObject,jsFlowExactObject,jsFlowNoise,jsFlowTypeof,jsFlowType,jsFlowGeneric,jsFlowMaybe,jsFlowParens,jsFlowOrOperator,jsFlowWildcard |
| 58 | + |
| 59 | +if version >= 508 || !exists("did_javascript_syn_inits") |
| 60 | + if version < 508 |
| 61 | + let did_javascript_syn_inits = 1 |
| 62 | + command -nargs=+ HiLink hi link <args> |
| 63 | + else |
| 64 | + command -nargs=+ HiLink hi def link <args> |
| 65 | + endif |
| 66 | + HiLink jsFlowDefinition PreProc |
| 67 | + HiLink jsFlowClassDef jsFlowDefinition |
| 68 | + HiLink jsFlowArgumentDef jsFlowDefinition |
| 69 | + HiLink jsFlowType Type |
| 70 | + HiLink jsFlowTypeCustom PreProc |
| 71 | + HiLink jsFlowTypeof PreProc |
| 72 | + HiLink jsFlowTypeofReturn PreProc |
| 73 | + HiLink jsFlowArray PreProc |
| 74 | + HiLink jsFlowObject PreProc |
| 75 | + HiLink jsFlowExactObject PreProc |
| 76 | + HiLink jsFlowParens PreProc |
| 77 | + HiLink jsFlowGeneric PreProc |
| 78 | + HiLink jsFlowObjectGeneric jsFlowGeneric |
| 79 | + HiLink jsFlowReturn PreProc |
| 80 | + HiLink jsFlowParenAnnotation PreProc |
| 81 | + HiLink jsFlowReturnObject jsFlowReturn |
| 82 | + HiLink jsFlowReturnArray jsFlowArray |
| 83 | + HiLink jsFlowReturnParens jsFlowParens |
| 84 | + HiLink jsFlowReturnGroup jsFlowGeneric |
| 85 | + HiLink jsFlowFunctionGroup PreProc |
| 86 | + HiLink jsFlowClassGroup PreProc |
| 87 | + HiLink jsFlowClassFunctionGroup PreProc |
| 88 | + HiLink jsFlowArrow PreProc |
| 89 | + HiLink jsFlowReturnArrow PreProc |
| 90 | + HiLink jsFlowTypeStatement PreProc |
| 91 | + HiLink jsFlowTypeKeyword PreProc |
| 92 | + HiLink jsFlowTypeOperator Operator |
| 93 | + HiLink jsFlowMaybe PreProc |
| 94 | + HiLink jsFlowReturnMaybe PreProc |
| 95 | + HiLink jsFlowClassProperty jsClassProperty |
| 96 | + HiLink jsFlowDeclare PreProc |
| 97 | + HiLink jsFlowModule PreProc |
| 98 | + HiLink jsFlowInterface PreProc |
| 99 | + HiLink jsFlowNoise Noise |
| 100 | + HiLink jsFlowObjectKey jsObjectKey |
| 101 | + HiLink jsFlowOrOperator jsOperator |
| 102 | + HiLink jsFlowReturnOrOp jsFlowOrOperator |
| 103 | + HiLink jsFlowWildcard PreProc |
| 104 | + HiLink jsFlowWildcardReturn PreProc |
| 105 | + HiLink jsFlowImportType PreProc |
| 106 | + HiLink jsFlowTypeValue PreProc |
| 107 | + HiLink jsFlowObjectFuncName jsObjectFuncName |
| 108 | + delcommand HiLink |
| 109 | +endif |
0 commit comments