Skip to content

Commit 82fb8b9

Browse files
committed
Adding some basic Flow support
This is by no means complete, and so far has only been to fix major syntax highlighting issues I've found.
1 parent 0115077 commit 82fb8b9

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

syntax/javascript.vim

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ syntax region jsParenIfElse contained matchgroup=jsParens s
134134
syntax region jsParenRepeat contained matchgroup=jsParens start=/(/ end=/)/ contains=@jsAll skipwhite skipempty nextgroup=jsBlock extend fold
135135
syntax region jsParenSwitch contained matchgroup=jsParens start=/(/ end=/)/ contains=@jsAll skipwhite skipempty nextgroup=jsSwitchBlock extend fold
136136
syntax region jsParenCatch contained matchgroup=jsParens start=/(/ end=/)/ skipwhite skipempty nextgroup=jsTryCatchBlock extend fold
137-
syntax region jsFuncArgs contained matchgroup=jsFuncParens start=/(/ end=/)/ contains=jsFuncArgCommas,jsComment,jsFuncArgExpression,jsDestructuringBlock,jsRestExpression skipwhite skipempty nextgroup=jsFuncBlock extend fold
137+
syntax region jsFuncArgs contained matchgroup=jsFuncParens start=/(/ end=/)/ contains=jsFuncArgCommas,jsComment,jsFuncArgExpression,jsDestructuringBlock,jsRestExpression skipwhite skipempty nextgroup=jsFuncBlock,jsFlow extend fold
138138
syntax region jsClassBlock contained matchgroup=jsClassBraces start=/{/ end=/}/ contains=jsClassFuncName,jsClassMethodDefinitions,jsOperator,jsArrowFunction,jsArrowFuncArgs,jsComment,jsGenerator,jsDecorator,jsClassProperty,jsClassPropertyComputed,jsClassStringKey,jsNoise extend fold
139139
syntax region jsFuncBlock contained matchgroup=jsFuncBraces start=/{/ end=/}/ contains=@jsAll extend fold
140140
syntax region jsBlock contained matchgroup=jsBraces start=/{/ end=/}/ contains=@jsAll extend fold
@@ -217,6 +217,13 @@ if !exists("javascript_ignore_javaScriptdoc")
217217
syntax region jsDocSeeTag contained matchgroup=jsDocSeeTag start="{" end="}" contains=jsDocTags
218218
endif "" JSDoc end
219219

220+
" FIXME: Will need to mask this behind an if statement, or make it a separate
221+
" file that gets source separately.
222+
syntax region jsFlow contained start=/:/ end=/[={),]\@=/ contains=jsFlowType skipwhite skipempty nextgroup=jsFuncBlock
223+
syntax keyword jsFlowType contained boolean number string null void any mixed JSON array function object
224+
syntax region jsFlowStatement start=/type/ end=/=/ skipwhite skipempty nextgroup=jsFlowObject
225+
syntax region jsFlowObject contained start=/{/ end=/}/
226+
220227
syntax cluster jsExpression contains=jsBracket,jsParen,jsObject,jsBlock,jsTernaryIf,jsTaggedTemplate,jsTemplateString,jsString,jsRegexpString,jsNumber,jsFloat,jsOperator,jsBooleanTrue,jsBooleanFalse,jsNull,jsFunction,jsArrowFunction,jsGlobalObjects,jsExceptions,jsFutureKeys,jsDomErrNo,jsDomNodeConsts,jsHtmlEvents,jsFuncCall,jsUndefined,jsNan,jsPrototype,jsBuiltins,jsNoise,jsClassDefinition,jsArrowFunction,jsArrowFuncArgs,jsParensError,jsComment,jsArguments,jsThis,jsSuper
221228
syntax cluster jsAll contains=@jsExpression,jsExportContainer,jsImportContainer,jsStorageClass,jsConditional,jsRepeat,jsReturn,jsStatement,jsException,jsTry,jsAsyncKeyword
222229

@@ -339,6 +346,9 @@ if version >= 508 || !exists("did_javascript_syn_inits")
339346
HiLink jsClassMethodDefinitions Type
340347
HiLink jsObjectGetSet Type
341348

349+
HiLink jsFlow PreProc
350+
HiLink jsFlowType Type
351+
342352
delcommand HiLink
343353
endif
344354

0 commit comments

Comments
 (0)