javascript.vim 4.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. " Remove interface from future keys
  2. syn clear jsFutureKeys
  3. syn keyword jsFutureKeys final implements goto long synchronized volatile transient float boolean protected abstract native double short char enum throws byte int package
  4. syn keyword tsAccessibility public private
  5. syn keyword tsPrimitives string any number object void
  6. syn keyword tsInterface interface nextgroup=tsInterfaceType,jsExtend skipwhite
  7. syn keyword jsExtend extends nextgroup=tsInterfaceType,tsType skipwhite
  8. syn match tsInterfaceType /\w\+/ nextgroup=jsBlock skipwhite contained
  9. syn cluster tsKeyword contains=@jsFutureKeys,tsAccessibility,tsPrimitives,tsInterface,jsExtend
  10. syn keyword jsExport export nextgroup=@jsAll,jsModuleGroup,jsExportDefault,jsModuleAsterisk,jsModuleKeyword,jsFlowTypeStatement,tsInterface skipwhite skipempty
  11. syn region jsClassBlock matchgroup=jsClassBraces start=/{/ end=/}/ contained extend fold contains=jsClassFuncName,jsClassMethodType,jsArrowFunction,jsArrowFuncArgs,jsComment,jsGenerator,jsDecorator,jsClassProperty,jsClassPropertyComputed,jsClassStringKey,jsAsyncKeyword,jsNoise,tsAccessibility
  12. syn match jsArrowFuncArgs /\<\K\k*\ze\s*=>/ extend contains=jsFuncArgs,tsPrimitives nextgroup=jsArrowFunction skipwhite skipempty
  13. syn region jsParen matchgroup=jsParens start=/(/ end=/)/ extend fold contains=@jsExpression,tsVariableType,tsPrimitives nextgroup=jsFlowDefinition,tsVariableType
  14. syn region jsFuncArgs matchgroup=jsFuncParens start=/(/ end=/)/ contains=jsFuncArgCommas,jsComment,jsFuncArgExpression,jsDestructuringBlock,jsDestructuringArray,jsRestExpression,jsFlowArgumentDef,tsVariableType,tsPrimitives,jsOperator nextgroup=jsCommentFunction,jsFuncBlock,jsFlowReturn,tsFuncReturnType skipwhite skipempty contained extend fold
  15. "syn region jsCommentFunction start=+//+ end=/$/ contained keepend extend contains=jsCommentTodo,@Spell nextgroup=jsFuncBlock,jsFlowReturn skipwhite skipempty start=+/\*+ end=+\*/+ contained keepend extend fold contains=jsCommentTodo,@Spell nextgroup=jsFuncBlock,jsFlowReturn skipwhite skipempty
  16. "syn match jsClassFuncName /\<\K\k*\ze\s*[(<]/ nextgroup=jsFuncArgs,jsFlowClassFunctionGroup skipwhite contained skipempty
  17. syn match jsVariableDef /\<\K\k*/ nextgroup=jsFlowDefinition,tsVariableType skipwhite skipempty contained
  18. syn match jsBlockLabel /\<\K\k*?\?\s*::\@!/ contains=jsNoise nextgroup=jsBlock skipwhite skipempty
  19. "syn region jsClassDefinition start=/\<class\>/ end=/\(\<extends\>\s\+\)\@<!{\@=/ contains=jsClassKeyword,jsExtendsKeyword,jsClassNoise,@jsExpression,jsFlowClassGroup,tsType,tsTypeArgAngleBrackets nextgroup=jsCommentClass,jsClassBlock,jsFlowClassGroup skipwhite skipempty
  20. syn region jsClassDefinition start=/\<class\>/ end=/\(\<extends\>\s\+\)\@<!{\@=/ contains=jsClassKeyword,jsExtendsKeyword,jsClassNoise,@jsExpression,jsFlowClassGroup,tsPrimitives nextgroup=jsCommentClass,jsClassBlock,jsFlowClassGroup skipwhite skipempty
  21. syn match tsVariableType /:\s\+\w\+\(.\w\+\)*/ nextgroup=jsFlowDefinition contains=tsTypeDecl,tsType,tsPrimitives,tsTypeArg skipwhite contained
  22. syn match tsFuncReturnType /:\s\+\w\+\(.\w\+\)*/ nextgroup=jsCommentFunction,jsFuncBlock,jsFlowReturn,jsFuncBraces,tsTypeArg contains=tsTypeDecl,tsType,tsTypeArg skipwhite contained
  23. syn match tsTypeDecl /:/ contained nextgroup=tsType
  24. syn match tsType /\w\+(\.\w\+)*/ nextgroup=tsTypeArg contained
  25. syn region tsTypeArg start=/</ end=/>/ matchgroup=tsTypeArgAngleBrackets contains=tsType,tsTypeArg,tsPrimitives,tsKeyword nextgroup=jsCommentFunction,jsFuncBlock,jsFlowReturn,jsFuncBraces skipwhite contained
  26. " Override the default definitions, adding/removing as necessary
  27. syn cluster jsAll contains=@jsExpression,jsStorageClass,jsConditional,jsRepeat,jsReturn,jsException,jsTry,jsNoise,jsBlockLabel,tsPrimitives
  28. syn clear jsTemplateString
  29. syn include @graphql ~/.vim/bundle/vim-graphql/syntax/graphql.vim
  30. syn region graphqlTemplate start=/graphql\s*`/ end=/`/ keepend contains=@graphql
  31. syn region jsTemplateString start=/`/ skip=/\\`/ end=/`/ extend contains=jsTemplateExpression,jsSpecial,@Spell
  32. hi link jsObjectKey Special
  33. hi link jsClassDefinition Type
  34. hi link jsFutureKeys Keyword
  35. hi link tsInterface Keyword
  36. hi link tsAccessibility Keyword
  37. hi link jsExtend Keyword
  38. hi link tsInterfaceType Type
  39. hi link tsPrimitives Special
  40. hi link tsType Type
  41. hi link tsFuncReturnType tsType
  42. hi link tsVariableType tsType
  43. hi link tsKeyword special