vim-polyglot/extras/flow.vim

114 lines
8.9 KiB
VimL
Raw Normal View History

if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'javascript') == -1
2016-09-11 07:24:17 -04:00
syntax region jsFlowDefinition contained start=/:/ end=/\%(\s*[,=;)\n]\)\@=/ contains=@jsFlowCluster containedin=jsParen
syntax region jsFlowArgumentDef contained start=/:/ end=/\%(\s*[,)]\|=>\@!\)\@=/ contains=@jsFlowCluster
2017-09-27 13:57:29 -04:00
syntax region jsFlowArray contained matchgroup=jsFlowNoise start=/\[/ end=/\]/ contains=@jsFlowCluster,jsComment fold
syntax region jsFlowObject contained matchgroup=jsFlowNoise start=/{/ end=/}/ contains=@jsFlowCluster,jsComment fold
syntax region jsFlowExactObject contained matchgroup=jsFlowNoise start=/{|/ end=/|}/ contains=@jsFlowCluster,jsComment fold
2019-03-04 03:15:44 -05:00
syntax region jsFlowParens contained matchgroup=jsFlowNoise start=/(/ end=/)/ contains=@jsFlowCluster nextgroup=jsFlowArrow skipwhite keepend extend fold
2016-09-11 07:24:17 -04:00
syntax match jsFlowNoise contained /[:;,<>]/
2017-02-02 15:16:29 -05:00
syntax keyword jsFlowType contained boolean number string null void any mixed JSON array Function object array bool class
2019-03-04 03:15:44 -05:00
syntax keyword jsFlowTypeof contained typeof skipempty skipwhite nextgroup=jsFlowTypeCustom,jsFlowType
syntax match jsFlowTypeCustom contained /[0-9a-zA-Z_.]*/ skipwhite skipempty nextgroup=jsFlowGeneric
syntax region jsFlowGeneric matchgroup=jsFlowNoise start=/\k\@<=</ end=/>/ contains=@jsFlowCluster containedin=@jsExpression,jsFlowDeclareBlock
syntax region jsFlowGeneric contained matchgroup=jsFlowNoise start=/</ end=/>(\@=/ oneline contains=@jsFlowCluster containedin=@jsExpression,jsFlowDeclareBlock
syntax region jsFlowObjectGeneric contained matchgroup=jsFlowNoise start=/\k\@<=</ end=/>/ contains=@jsFlowCluster nextgroup=jsFuncArgs
2016-07-30 07:18:40 -04:00
syntax match jsFlowArrow contained /=>/ skipwhite skipempty nextgroup=jsFlowType,jsFlowTypeCustom,jsFlowParens
syntax match jsFlowObjectKey contained /[0-9a-zA-Z_$?]*\(\s*:\)\@=/ contains=jsFunctionKey,jsFlowMaybe skipwhite skipempty nextgroup=jsObjectValue containedin=jsObject
syntax match jsFlowOrOperator contained /|/ skipwhite skipempty nextgroup=@jsFlowCluster
2018-07-08 09:16:28 -04:00
syntax keyword jsFlowImportType contained type typeof skipwhite skipempty nextgroup=jsModuleAsterisk,jsModuleKeyword,jsModuleGroup
2017-02-02 15:16:29 -05:00
syntax match jsFlowWildcard contained /*/
2016-07-30 07:18:40 -04:00
2017-09-27 13:57:29 -04:00
syntax match jsFlowReturn contained /:\s*/ contains=jsFlowNoise skipwhite skipempty nextgroup=@jsFlowReturnCluster,jsFlowArrow,jsFlowReturnParens
2019-03-04 03:15:44 -05:00
syntax region jsFlowReturnObject contained matchgroup=jsFlowNoise start=/{/ end=/}/ contains=@jsFlowCluster skipwhite skipempty nextgroup=jsFuncBlock,jsFlowReturnOrOp extend fold
2017-09-27 13:57:29 -04:00
syntax region jsFlowReturnArray contained matchgroup=jsFlowNoise start=/\[/ end=/\]/ contains=@jsFlowCluster skipwhite skipempty nextgroup=jsFuncBlock,jsFlowReturnOrOp fold
syntax region jsFlowReturnParens contained matchgroup=jsFlowNoise start=/(/ end=/)/ contains=@jsFlowCluster skipwhite skipempty nextgroup=jsFuncBlock,jsFlowReturnOrOp,jsFlowReturnArrow fold
syntax match jsFlowReturnArrow contained /=>/ skipwhite skipempty nextgroup=@jsFlowReturnCluster
2018-07-08 09:16:28 -04:00
syntax match jsFlowReturnKeyword contained /\k\+/ contains=jsFlowType,jsFlowTypeCustom skipwhite skipempty nextgroup=jsFlowReturnGroup,jsFuncBlock,jsFlowReturnOrOp,jsFlowReturnArray
2018-12-26 04:41:57 -05:00
syntax match jsFlowReturnMaybe contained /?/ skipwhite skipempty nextgroup=jsFlowReturnKeyword,jsFlowReturnObject,jsFlowReturnParens
2016-07-30 07:18:40 -04:00
syntax region jsFlowReturnGroup contained matchgroup=jsFlowNoise start=/</ end=/>/ contains=@jsFlowCluster skipwhite skipempty nextgroup=jsFuncBlock,jsFlowReturnOrOp
syntax match jsFlowReturnOrOp contained /\s*|\s*/ skipwhite skipempty nextgroup=@jsFlowReturnCluster
2017-02-02 15:16:29 -05:00
syntax match jsFlowWildcardReturn contained /*/ skipwhite skipempty nextgroup=jsFuncBlock
2019-03-04 03:15:44 -05:00
syntax keyword jsFlowTypeofReturn contained typeof skipempty skipwhite nextgroup=@jsFlowReturnCluster
2016-07-30 07:18:40 -04:00
syntax region jsFlowFunctionGroup contained matchgroup=jsFlowNoise start=/</ end=/>/ contains=@jsFlowCluster skipwhite skipempty nextgroup=jsFuncArgs
syntax region jsFlowClassGroup contained matchgroup=jsFlowNoise start=/</ end=/>/ contains=@jsFlowCluster skipwhite skipempty nextgroup=jsClassBlock
syntax region jsFlowClassFunctionGroup contained matchgroup=jsFlowNoise start=/</ end=/>/ contains=@jsFlowCluster skipwhite skipempty nextgroup=jsFuncArgs
2019-03-04 03:15:44 -05:00
syntax match jsFlowObjectFuncName contained /\<\K\k*<\@=/ skipwhite skipempty nextgroup=jsFlowObjectGeneric containedin=jsObject
2016-07-30 07:18:40 -04:00
2018-06-05 16:50:18 -04:00
syntax region jsFlowTypeStatement start=/\(opaque\s\+\)\?type\%(\s\+\k\)\@=/ end=/=\@=/ contains=jsFlowTypeOperator oneline skipwhite skipempty nextgroup=jsFlowTypeValue keepend
2019-03-04 03:15:44 -05:00
syntax region jsFlowTypeValue contained matchgroup=jsFlowNoise start=/=/ end=/\%(;\|\n\%(\s*|\)\@!\)/ contains=@jsFlowCluster,jsFlowGeneric,jsFlowMaybe
2017-09-27 13:57:29 -04:00
syntax match jsFlowTypeOperator contained /=/ containedin=jsFlowTypeValue
2016-07-30 07:18:40 -04:00
syntax match jsFlowTypeOperator contained /=/
syntax keyword jsFlowTypeKeyword contained type
syntax keyword jsFlowDeclare declare skipwhite skipempty nextgroup=jsFlowTypeStatement,jsClassDefinition,jsStorageClass,jsFlowModule,jsFlowInterface
syntax match jsFlowClassProperty contained /\<[0-9a-zA-Z_$]*\>:\@=/ skipwhite skipempty nextgroup=jsFlowClassDef containedin=jsClassBlock
syntax region jsFlowClassDef contained start=/:/ end=/\%(\s*[,=;)\n]\)\@=/ contains=@jsFlowCluster skipwhite skipempty nextgroup=jsClassValue
2019-03-04 03:15:44 -05:00
syntax region jsFlowModule contained start=/module/ end=/\%({\|:\)\@=/ skipempty skipwhite nextgroup=jsFlowDeclareBlock contains=jsString
syntax region jsFlowInterface contained start=/interface/ end=/{\@=/ skipempty skipwhite nextgroup=jsFlowInterfaceBlock contains=@jsFlowCluster
2017-09-27 13:57:29 -04:00
syntax region jsFlowDeclareBlock contained matchgroup=jsFlowNoise start=/{/ end=/}/ contains=jsFlowDeclare,jsFlowNoise fold
2016-07-30 07:18:40 -04:00
2017-09-27 13:57:29 -04:00
syntax match jsFlowMaybe contained /?/
2019-03-04 03:15:44 -05:00
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
2016-07-30 07:18:40 -04:00
2017-09-27 13:57:29 -04:00
syntax region jsFlowParenAnnotation contained start=/:/ end=/[,=)]\@=/ containedin=jsParen contains=@jsFlowCluster
2019-03-04 03:15:44 -05:00
syntax cluster jsFlowReturnCluster contains=jsFlowNoise,jsFlowReturnObject,jsFlowReturnArray,jsFlowReturnKeyword,jsFlowReturnGroup,jsFlowReturnMaybe,jsFlowReturnOrOp,jsFlowWildcardReturn,jsFlowReturnArrow,jsFlowTypeofReturn
syntax cluster jsFlowCluster contains=jsFlowArray,jsFlowObject,jsFlowExactObject,jsFlowNoise,jsFlowTypeof,jsFlowType,jsFlowGeneric,jsFlowMaybe,jsFlowParens,jsFlowOrOperator,jsFlowWildcard
2016-07-30 07:18:40 -04:00
if version >= 508 || !exists("did_javascript_syn_inits")
if version < 508
let did_javascript_syn_inits = 1
command -nargs=+ HiLink hi link <args>
else
command -nargs=+ HiLink hi def link <args>
endif
HiLink jsFlowDefinition PreProc
HiLink jsFlowClassDef jsFlowDefinition
HiLink jsFlowArgumentDef jsFlowDefinition
HiLink jsFlowType Type
HiLink jsFlowTypeCustom PreProc
HiLink jsFlowTypeof PreProc
2019-03-04 03:15:44 -05:00
HiLink jsFlowTypeofReturn PreProc
2016-07-30 07:18:40 -04:00
HiLink jsFlowArray PreProc
HiLink jsFlowObject PreProc
2017-09-27 13:57:29 -04:00
HiLink jsFlowExactObject PreProc
2016-07-30 07:18:40 -04:00
HiLink jsFlowParens PreProc
2019-03-04 03:15:44 -05:00
HiLink jsFlowGeneric PreProc
HiLink jsFlowObjectGeneric jsFlowGeneric
2016-07-30 07:18:40 -04:00
HiLink jsFlowReturn PreProc
2017-09-27 13:57:29 -04:00
HiLink jsFlowParenAnnotation PreProc
2016-07-30 07:18:40 -04:00
HiLink jsFlowReturnObject jsFlowReturn
HiLink jsFlowReturnArray jsFlowArray
HiLink jsFlowReturnParens jsFlowParens
2019-03-04 03:15:44 -05:00
HiLink jsFlowReturnGroup jsFlowGeneric
2016-07-30 07:18:40 -04:00
HiLink jsFlowFunctionGroup PreProc
HiLink jsFlowClassGroup PreProc
HiLink jsFlowClassFunctionGroup PreProc
2016-07-30 07:18:40 -04:00
HiLink jsFlowArrow PreProc
2017-09-27 13:57:29 -04:00
HiLink jsFlowReturnArrow PreProc
2016-07-30 07:18:40 -04:00
HiLink jsFlowTypeStatement PreProc
HiLink jsFlowTypeKeyword PreProc
2017-09-27 13:57:29 -04:00
HiLink jsFlowTypeOperator Operator
2016-07-30 07:18:40 -04:00
HiLink jsFlowMaybe PreProc
HiLink jsFlowReturnMaybe PreProc
HiLink jsFlowClassProperty jsClassProperty
HiLink jsFlowDeclare PreProc
HiLink jsFlowModule PreProc
HiLink jsFlowInterface PreProc
HiLink jsFlowNoise Noise
HiLink jsFlowObjectKey jsObjectKey
2017-09-27 13:57:29 -04:00
HiLink jsFlowOrOperator jsOperator
2016-07-30 07:18:40 -04:00
HiLink jsFlowReturnOrOp jsFlowOrOperator
2017-02-02 15:16:29 -05:00
HiLink jsFlowWildcard PreProc
HiLink jsFlowWildcardReturn PreProc
2017-09-27 13:57:29 -04:00
HiLink jsFlowImportType PreProc
HiLink jsFlowTypeValue PreProc
2019-03-04 03:15:44 -05:00
HiLink jsFlowObjectFuncName jsObjectFuncName
2016-07-30 07:18:40 -04:00
delcommand HiLink
endif
endif