Skip to content

Commit 9d0bea5

Browse files
committed
Masking Flow support behind a global var
1 parent 5f839a2 commit 9d0bea5

2 files changed

Lines changed: 34 additions & 23 deletions

File tree

extras/flow.vim

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
syntax region jsFlowTypeStatement start=/type/ end=/=/ oneline skipwhite skipempty nextgroup=jsFlowTypeObject
2+
syntax region jsFlowDeclareBlock start=/declare/ end=/[;\n]/ oneline contains=jsFlow,jsFlowDeclareKeyword,jsFlowStorageClass
3+
syntax region jsFlow start=/:/ end=/\%(\%([),=;\n]\|{\%(.*}\)\@!\|\%({.*}\)\@<=\s*{\)\@=\|void\)/ contains=@jsFlowCluster oneline skipwhite skipempty nextgroup=jsFuncBlock
4+
syntax region jsFlowReturn contained start=/:/ end=/\%(\S\s*\%({\)\@=\|\n\)/ contains=@jsFlowCluster oneline skipwhite skipempty nextgroup=jsFuncBlock keepend
5+
syntax region jsFlowTypeObject contained start=/{/ end=/}/ skipwhite skipempty nextgroup=jsFunctionBlock extend
6+
syntax region jsFlowObject contained matchgroup=jsFlowNoise start=/{/ end=/}/ oneline contains=@jsFlowCluster
7+
syntax region jsFlowArray contained matchgroup=jsFlowNoise start=/\[/ end=/\]/ oneline contains=@jsFlowCluster
8+
syntax keyword jsFlowDeclareKeyword contained declare
9+
syntax keyword jsFlowType contained boolean number string null void any mixed JSON array function object Array
10+
syntax match jsFlowClassProperty contained /\<[0-9a-zA-Z_$]*\>:\@=/ skipwhite skipempty nextgroup=jsFlow
11+
syntax match jsFlowNoise contained /[:;,<>]/
12+
syntax cluster jsFlowCluster contains=jsFlowType,jsFlowArray,jsFlowObject,jsFlowNoise
13+
syntax keyword jsFlowStorageClass contained const var let
14+
15+
if version >= 508 || !exists("did_javascript_syn_inits")
16+
if version < 508
17+
let did_javascript_syn_inits = 1
18+
command -nargs=+ HiLink hi link <args>
19+
else
20+
command -nargs=+ HiLink hi def link <args>
21+
endif
22+
HiLink jsFlow PreProc
23+
HiLink jsFlowReturn PreProc
24+
HiLink jsFlowArray PreProc
25+
HiLink jsFlowDeclareBlock PreProc
26+
HiLink jsFlowObject PreProc
27+
HiLink jsFlowType Type
28+
HiLink jsFlowDeclareKeyword Type
29+
HiLink jsFlowNoise Noise
30+
delcommand HiLink
31+
endif

syntax/javascript.vim

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -218,20 +218,9 @@ if !exists("javascript_ignore_javaScriptdoc")
218218
syntax region jsDocSeeTag contained matchgroup=jsDocSeeTag start="{" end="}" contains=jsDocTags
219219
endif "" JSDoc end
220220

221-
" FIXME: Will need to mask this behind an if statement, or make it a separate file that gets source separately.
222-
syntax region jsFlowTypeStatement start=/type/ end=/=/ oneline skipwhite skipempty nextgroup=jsFlowTypeObject
223-
syntax region jsFlowDeclareBlock start=/declare/ end=/[;\n]/ oneline contains=jsFlow,jsFlowDeclareKeyword,jsFlowStorageClass
224-
syntax region jsFlow start=/:/ end=/\%(\%([),=;\n]\|{\%(.*}\)\@!\|\%({.*}\)\@<=\s*{\)\@=\|void\)/ contains=@jsFlowCluster oneline skipwhite skipempty nextgroup=jsFuncBlock
225-
syntax region jsFlowReturn contained start=/:/ end=/\%(\S\s*\%({\)\@=\|\n\)/ contains=@jsFlowCluster oneline skipwhite skipempty nextgroup=jsFuncBlock keepend
226-
syntax region jsFlowTypeObject contained start=/{/ end=/}/ skipwhite skipempty nextgroup=jsFunctionBlock extend
227-
syntax region jsFlowObject contained matchgroup=jsFlowNoise start=/{/ end=/}/ oneline contains=@jsFlowCluster
228-
syntax region jsFlowArray contained matchgroup=jsFlowNoise start=/\[/ end=/\]/ oneline contains=@jsFlowCluster
229-
syntax keyword jsFlowDeclareKeyword contained declare
230-
syntax keyword jsFlowType contained boolean number string null void any mixed JSON array function object Array
231-
syntax match jsFlowClassProperty contained /\<[0-9a-zA-Z_$]*\>:\@=/ skipwhite skipempty nextgroup=jsFlow
232-
syntax match jsFlowNoise contained /[:;,<>]/
233-
syntax cluster jsFlowCluster contains=jsFlowType,jsFlowArray,jsFlowObject,jsFlowNoise
234-
syntax keyword jsFlowStorageClass contained const var let
221+
if exists("javascript_plugin_flow")
222+
syntax include extras/flow.vim
223+
endif
235224

236225
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
237226
syntax cluster jsAll contains=@jsExpression,jsExportContainer,jsImportContainer,jsStorageClass,jsConditional,jsRepeat,jsReturn,jsStatement,jsException,jsTry,jsAsyncKeyword
@@ -355,15 +344,6 @@ if version >= 508 || !exists("did_javascript_syn_inits")
355344
HiLink jsClassMethodDefinitions Type
356345
HiLink jsObjectGetSet Type
357346

358-
HiLink jsFlow PreProc
359-
HiLink jsFlowReturn PreProc
360-
HiLink jsFlowArray PreProc
361-
HiLink jsFlowDeclareBlock PreProc
362-
HiLink jsFlowObject PreProc
363-
HiLink jsFlowType Type
364-
HiLink jsFlowDeclareKeyword Type
365-
HiLink jsFlowNoise Noise
366-
367347
delcommand HiLink
368348
endif
369349

0 commit comments

Comments
 (0)