Run a build and commit the results

This commit is contained in:
Danielle McLean
2023-10-10 23:21:12 +11:00
parent 158ffef943
commit a126d20c24
815 changed files with 3403 additions and 89318 deletions

View File

@@ -0,0 +1,69 @@
if polyglot#init#is_disabled(expand('<sfile>:p'), 'typescript', 'syntax/ts-common/class.vim')
finish
endif
"don't add typescriptMembers to nextgroup, let outer scope match it
" so we won't match abstract method outside abstract class
syntax keyword typescriptAbstract abstract
\ nextgroup=typescriptClassKeyword
\ skipwhite skipnl
syntax keyword typescriptClassKeyword class
\ nextgroup=typescriptClassName,typescriptClassExtends,typescriptClassBlock
\ skipwhite
syntax match typescriptClassName contained /\K\k*/
\ nextgroup=typescriptClassBlock,typescriptClassExtends,typescriptClassTypeParameter
\ skipwhite skipnl
syntax region typescriptClassTypeParameter
\ start=/</ end=/>/
\ contains=@typescriptTypeParameterCluster
\ nextgroup=typescriptClassBlock,typescriptClassExtends
\ contained skipwhite skipnl
syntax keyword typescriptClassExtends contained extends implements nextgroup=typescriptClassHeritage skipwhite skipnl
syntax match typescriptClassHeritage contained /\v(\k|\.|\(|\))+/
\ nextgroup=typescriptClassBlock,typescriptClassExtends,typescriptMixinComma,typescriptClassTypeArguments
\ contains=@typescriptValue
\ skipwhite skipnl
\ contained
syntax region typescriptClassTypeArguments matchgroup=typescriptTypeBrackets
\ start=/</ end=/>/
\ contains=@typescriptType
\ nextgroup=typescriptClassExtends,typescriptClassBlock,typescriptMixinComma
\ contained skipwhite skipnl
syntax match typescriptMixinComma /,/ contained nextgroup=typescriptClassHeritage skipwhite skipnl
" we need add arrowFunc to class block for high order arrow func
" see test case
syntax region typescriptClassBlock matchgroup=typescriptBraces start=/{/ end=/}/
\ contains=@typescriptPropertyMemberDeclaration,typescriptAbstract,@typescriptComments,typescriptBlock,typescriptAssign,typescriptDecorator,typescriptAsyncFuncKeyword,typescriptArrowFunc
\ contained fold
syntax keyword typescriptInterfaceKeyword interface nextgroup=typescriptInterfaceName skipwhite
syntax match typescriptInterfaceName contained /\k\+/
\ nextgroup=typescriptObjectType,typescriptInterfaceExtends,typescriptInterfaceTypeParameter
\ skipwhite skipnl
syntax region typescriptInterfaceTypeParameter
\ start=/</ end=/>/
\ contains=@typescriptTypeParameterCluster
\ nextgroup=typescriptObjectType,typescriptInterfaceExtends
\ contained
\ skipwhite skipnl
syntax keyword typescriptInterfaceExtends contained extends nextgroup=typescriptInterfaceHeritage skipwhite skipnl
syntax match typescriptInterfaceHeritage contained /\v(\k|\.)+/
\ nextgroup=typescriptObjectType,typescriptInterfaceComma,typescriptInterfaceTypeArguments
\ skipwhite
syntax region typescriptInterfaceTypeArguments matchgroup=typescriptTypeBrackets
\ start=/</ end=/>/ skip=/\s*,\s*/
\ contains=@typescriptType
\ nextgroup=typescriptObjectType,typescriptInterfaceComma
\ contained skipwhite
syntax match typescriptInterfaceComma /,/ contained nextgroup=typescriptInterfaceHeritage skipwhite skipnl

View File

@@ -0,0 +1,42 @@
if polyglot#init#is_disabled(expand('<sfile>:p'), 'typescript', 'syntax/ts-common/cluster.vim')
finish
endif
"Block VariableStatement EmptyStatement ExpressionStatement IfStatement IterationStatement ContinueStatement BreakStatement ReturnStatement WithStatement LabelledStatement SwitchStatement ThrowStatement TryStatement DebuggerStatement
syntax cluster typescriptStatement
\ contains=typescriptBlock,typescriptVariable,typescriptUsing,
\ @typescriptTopExpression,typescriptAssign,
\ typescriptConditional,typescriptRepeat,typescriptBranch,
\ typescriptLabel,typescriptStatementKeyword,
\ typescriptFuncKeyword,
\ typescriptTry,typescriptExceptions,typescriptDebugger,
\ typescriptExport,typescriptInterfaceKeyword,typescriptEnum,
\ typescriptModule,typescriptAliasKeyword,typescriptImport
syntax cluster typescriptPrimitive contains=typescriptString,typescriptTemplate,typescriptRegexpString,typescriptNumber,typescriptBoolean,typescriptNull,typescriptArray
syntax cluster typescriptEventTypes contains=typescriptEventString,typescriptTemplate,typescriptNumber,typescriptBoolean,typescriptNull
" top level expression: no arrow func
" also no func keyword. funcKeyword is contained in statement
" funcKeyword allows overloading (func without body)
" funcImpl requires body
syntax cluster typescriptTopExpression
\ contains=@typescriptPrimitive,
\ typescriptIdentifier,typescriptIdentifierName,
\ typescriptOperator,typescriptUnaryOp,
\ typescriptParenExp,typescriptRegexpString,
\ typescriptGlobal,typescriptAsyncFuncKeyword,
\ typescriptClassKeyword,typescriptTypeCast
" no object literal, used in type cast and arrow func
" TODO: change func keyword to funcImpl
syntax cluster typescriptExpression
\ contains=@typescriptTopExpression,
\ typescriptArrowFuncDef,
\ typescriptFuncImpl
syntax cluster typescriptValue
\ contains=@typescriptExpression,typescriptObjectLiteral
syntax cluster typescriptEventExpression contains=typescriptArrowFuncDef,typescriptParenExp,@typescriptValue,typescriptRegexpString,@typescriptEventTypes,typescriptOperator,typescriptGlobal,jsxRegion

View File

@@ -0,0 +1,7 @@
if polyglot#init#is_disabled(expand('<sfile>:p'), 'typescript', 'syntax/ts-common/decorator.vim')
finish
endif
syntax match typescriptDecorator /@\([_$a-zA-Z][_$a-zA-Z0-9]*\.\)*[_$a-zA-Z][_$a-zA-Z0-9]*\>/
\ nextgroup=typescriptFuncCallArg,typescriptTypeArguments
\ contains=@_semantic,typescriptDotNotation

88
syntax/ts-common/doc.vim Normal file
View File

@@ -0,0 +1,88 @@
if polyglot#init#is_disabled(expand('<sfile>:p'), 'typescript', 'syntax/ts-common/doc.vim')
finish
endif
"Syntax coloring for Node.js shebang line
syntax match shellbang "^#!.*node\>"
syntax match shellbang "^#!.*iojs\>"
"JavaScript comments
syntax keyword typescriptCommentTodo TODO FIXME XXX TBD
syntax match typescriptMagicComment "@ts-\%(ignore\|expect-error\)\>"
syntax match typescriptLineComment "//.*"
\ contains=@Spell,typescriptCommentTodo,typescriptRef,typescriptMagicComment
syntax region typescriptComment
\ start="/\*" end="\*/"
\ contains=@Spell,typescriptCommentTodo extend
syntax cluster typescriptComments
\ contains=typescriptDocComment,typescriptComment,typescriptLineComment
syntax match typescriptRef +///\s*<reference\s\+.*\/>$+
\ contains=typescriptString
syntax match typescriptRef +///\s*<amd-dependency\s\+.*\/>$+
\ contains=typescriptString
syntax match typescriptRef +///\s*<amd-module\s\+.*\/>$+
\ contains=typescriptString
"JSDoc
syntax case ignore
syntax region typescriptDocComment matchgroup=typescriptComment
\ start="/\*\*" end="\*/"
\ contains=typescriptDocNotation,typescriptCommentTodo,@Spell
\ fold keepend
syntax match typescriptDocNotation contained /@/ nextgroup=typescriptDocTags
syntax keyword typescriptDocTags contained constant constructor constructs function ignore inner private public readonly static
syntax keyword typescriptDocTags contained const dict expose inheritDoc interface nosideeffects override protected struct internal
syntax keyword typescriptDocTags contained example global
syntax keyword typescriptDocTags contained alpha beta defaultValue eventProperty experimental label
syntax keyword typescriptDocTags contained packageDocumentation privateRemarks remarks sealed typeParam
" syntax keyword typescriptDocTags contained ngdoc nextgroup=typescriptDocNGDirective
syntax keyword typescriptDocTags contained ngdoc scope priority animations
syntax keyword typescriptDocTags contained ngdoc restrict methodOf propertyOf eventOf eventType nextgroup=typescriptDocParam skipwhite
syntax keyword typescriptDocNGDirective contained overview service object function method property event directive filter inputType error
syntax keyword typescriptDocTags contained abstract virtual access augments
syntax keyword typescriptDocTags contained arguments callback lends memberOf name type kind link mixes mixin tutorial nextgroup=typescriptDocParam skipwhite
syntax keyword typescriptDocTags contained variation nextgroup=typescriptDocNumParam skipwhite
syntax keyword typescriptDocTags contained author class classdesc copyright default defaultvalue nextgroup=typescriptDocDesc skipwhite
syntax keyword typescriptDocTags contained deprecated description external host nextgroup=typescriptDocDesc skipwhite
syntax keyword typescriptDocTags contained file fileOverview overview namespace requires since version nextgroup=typescriptDocDesc skipwhite
syntax keyword typescriptDocTags contained summary todo license preserve nextgroup=typescriptDocDesc skipwhite
syntax keyword typescriptDocTags contained borrows exports nextgroup=typescriptDocA skipwhite
syntax keyword typescriptDocTags contained param arg argument property prop module nextgroup=typescriptDocNamedParamType,typescriptDocParamName skipwhite
syntax keyword typescriptDocTags contained define enum extends implements this typedef nextgroup=typescriptDocParamType skipwhite
syntax keyword typescriptDocTags contained return returns throws exception nextgroup=typescriptDocParamType,typescriptDocParamName skipwhite
syntax keyword typescriptDocTags contained see nextgroup=typescriptDocRef skipwhite
syntax keyword typescriptDocTags contained function func method nextgroup=typescriptDocName skipwhite
syntax match typescriptDocName contained /\h\w*/
syntax keyword typescriptDocTags contained fires event nextgroup=typescriptDocEventRef skipwhite
syntax match typescriptDocEventRef contained /\h\w*#\(\h\w*\:\)\?\h\w*/
syntax match typescriptDocNamedParamType contained /{.\+}/ nextgroup=typescriptDocParamName skipwhite
syntax match typescriptDocParamName contained /\[\?0-9a-zA-Z_\.]\+\]\?/ nextgroup=typescriptDocDesc skipwhite
syntax match typescriptDocParamType contained /{.\+}/ nextgroup=typescriptDocDesc skipwhite
syntax match typescriptDocA contained /\%(#\|\w\|\.\|:\|\/\)\+/ nextgroup=typescriptDocAs skipwhite
syntax match typescriptDocAs contained /\s*as\s*/ nextgroup=typescriptDocB skipwhite
syntax match typescriptDocB contained /\%(#\|\w\|\.\|:\|\/\)\+/
syntax match typescriptDocParam contained /\%(#\|\w\|\.\|:\|\/\|-\)\+/
syntax match typescriptDocNumParam contained /\d\+/
syntax match typescriptDocRef contained /\%(#\|\w\|\.\|:\|\/\)\+/
syntax region typescriptDocLinkTag contained matchgroup=typescriptDocLinkTag start=/{/ end=/}/ contains=typescriptDocTags
syntax cluster typescriptDocs contains=typescriptDocParamType,typescriptDocNamedParamType,typescriptDocParam
if exists("main_syntax") && main_syntax == "typescript"
syntax sync clear
syntax sync ccomment typescriptComment minlines=200
endif
syntax case match

View File

@@ -0,0 +1,63 @@
if polyglot#init#is_disabled(expand('<sfile>:p'), 'typescript', 'syntax/ts-common/function.vim')
finish
endif
syntax keyword typescriptAsyncFuncKeyword async
\ nextgroup=typescriptFuncKeyword,typescriptArrowFuncDef,typescriptArrowFuncTypeParameter
\ skipwhite
syntax keyword typescriptAsyncFuncKeyword await
\ nextgroup=@typescriptValue,typescriptUsing
\ skipwhite
exec 'syntax keyword typescriptFuncKeyword '.(exists('g:typescript_conceal_function') ? 'conceal cchar='.g:typescript_conceal_function : '').' function nextgroup=typescriptAsyncFunc,typescriptFuncName,@typescriptCallSignature skipwhite skipempty'
syntax match typescriptAsyncFunc contained /*/
\ nextgroup=typescriptFuncName,@typescriptCallSignature
\ skipwhite skipempty
syntax match typescriptFuncName contained /\K\k*/
\ nextgroup=@typescriptCallSignature
\ skipwhite
syntax match typescriptArrowFuncDef contained /\K\k*\s*=>/
\ contains=typescriptArrowFuncArg,typescriptArrowFunc
\ nextgroup=@typescriptExpression,typescriptBlock
\ skipwhite skipempty
syntax match typescriptArrowFuncDef contained /(\%(\_[^()]\+\|(\_[^()]*)\)*)\_s*=>/
\ contains=typescriptArrowFuncArg,typescriptArrowFunc,@typescriptCallSignature
\ nextgroup=@typescriptExpression,typescriptBlock
\ skipwhite skipempty
syntax region typescriptArrowFuncDef contained start=/(\%(\_[^()]\+\|(\_[^()]*)\)*):/ matchgroup=typescriptArrowFunc end=/=>/
\ contains=typescriptArrowFuncArg,typescriptTypeAnnotation,@typescriptCallSignature
\ nextgroup=@typescriptExpression,typescriptBlock
\ skipwhite skipempty keepend
syntax region typescriptArrowFuncTypeParameter start=/</ end=/>/
\ contains=@typescriptTypeParameterCluster
\ nextgroup=typescriptArrowFuncDef
\ contained skipwhite skipnl
syntax match typescriptArrowFunc /=>/
syntax match typescriptArrowFuncArg contained /\K\k*/
syntax region typescriptReturnAnnotation contained start=/:/ end=/{/me=e-1 contains=@typescriptType nextgroup=typescriptBlock
syntax region typescriptFuncImpl contained start=/function\>/ end=/{\|;\|\n/me=e-1
\ contains=typescriptFuncKeyword
\ nextgroup=typescriptBlock
syntax cluster typescriptCallImpl contains=typescriptGenericImpl,typescriptParamImpl
syntax region typescriptGenericImpl matchgroup=typescriptTypeBrackets
\ start=/</ end=/>/ skip=/\s*,\s*/
\ contains=typescriptTypeParameter
\ nextgroup=typescriptParamImpl
\ contained skipwhite
syntax region typescriptParamImpl matchgroup=typescriptParens
\ start=/(/ end=/)/
\ contains=typescriptDecorator,@typescriptParameterList,@typescriptComments
\ nextgroup=typescriptReturnAnnotation,typescriptBlock
\ contained skipwhite skipnl

View File

@@ -0,0 +1,83 @@
if polyglot#init#is_disabled(expand('<sfile>:p'), 'typescript', 'syntax/ts-common/identifiers.vim')
finish
endif
syntax cluster afterIdentifier contains=
\ typescriptDotNotation,
\ typescriptFuncCallArg,
\ typescriptTemplate,
\ typescriptIndexExpr,
\ @typescriptSymbols,
\ typescriptTypeArguments
syntax match typescriptIdentifierName /\<\K\k*/
\ nextgroup=@afterIdentifier
\ transparent
\ contains=@_semantic
\ skipnl skipwhite
syntax match typescriptProp contained /\K\k*!\?/
\ transparent
\ contains=@props
\ nextgroup=@afterIdentifier
\ skipwhite skipempty
syntax region typescriptIndexExpr contained matchgroup=typescriptProperty start=/\[/ end=/]/ contains=@typescriptValue,typescriptCastKeyword nextgroup=@typescriptSymbols,typescriptDotNotation,typescriptFuncCallArg skipwhite skipempty
syntax match typescriptDotNotation /\.\|?\.\|!\./ nextgroup=typescriptProp skipnl
syntax match typescriptDotStyleNotation /\.style\./ nextgroup=typescriptDOMStyle transparent
" syntax match typescriptFuncCall contained /[a-zA-Z]\k*\ze(/ nextgroup=typescriptFuncCallArg
syntax region typescriptParenExp matchgroup=typescriptParens start=/(/ end=/)/ contains=@typescriptComments,@typescriptValue,typescriptCastKeyword nextgroup=@typescriptSymbols skipwhite skipempty
syntax region typescriptFuncCallArg contained matchgroup=typescriptParens start=/(/ end=/)/ contains=@typescriptValue,@typescriptComments,typescriptCastKeyword nextgroup=@typescriptSymbols,typescriptDotNotation skipwhite skipempty skipnl
syntax region typescriptEventFuncCallArg contained matchgroup=typescriptParens start=/(/ end=/)/ contains=@typescriptEventExpression
syntax region typescriptEventString contained start=/\z(["']\)/ skip=/\\\\\|\\\z1\|\\\n/ end=/\z1\|$/ contains=typescriptASCII,@events
syntax region typescriptDestructureString
\ start=/\z(["']\)/ skip=/\\\\\|\\\z1\|\\\n/ end=/\z1\|$/
\ contains=typescriptASCII
\ nextgroup=typescriptDestructureAs
\ contained skipwhite skipempty
syntax cluster typescriptVariableDeclarations
\ contains=typescriptVariableDeclaration,@typescriptDestructures
syntax match typescriptVariableDeclaration /[A-Za-z_$]\k*/
\ nextgroup=typescriptTypeAnnotation,typescriptAssign
\ contained skipwhite skipempty
syntax cluster typescriptDestructureVariables contains=
\ typescriptRestOrSpread,
\ typescriptDestructureComma,
\ typescriptDestructureLabel,
\ typescriptDestructureVariable,
\ @typescriptDestructures
syntax match typescriptDestructureVariable /[A-Za-z_$]\k*/ contained
\ nextgroup=typescriptDefaultParam
\ contained skipwhite skipempty
syntax match typescriptDestructureLabel /[A-Za-z_$]\k*\ze\_s*:/
\ nextgroup=typescriptDestructureAs
\ contained skipwhite skipempty
syntax match typescriptDestructureAs /:/
\ nextgroup=typescriptDestructureVariable,@typescriptDestructures
\ contained skipwhite skipempty
syntax match typescriptDestructureComma /,/ contained
syntax cluster typescriptDestructures contains=
\ typescriptArrayDestructure,
\ typescriptObjectDestructure
syntax region typescriptArrayDestructure matchgroup=typescriptBraces
\ start=/\[/ end=/]/
\ contains=@typescriptDestructureVariables,@typescriptComments
\ nextgroup=typescriptTypeAnnotation,typescriptAssign
\ transparent contained skipwhite skipempty fold
syntax region typescriptObjectDestructure matchgroup=typescriptBraces
\ start=/{/ end=/}/
\ contains=typescriptDestructureString,@typescriptDestructureVariables,@typescriptComments
\ nextgroup=typescriptTypeAnnotation,typescriptAssign
\ transparent contained skipwhite skipempty fold

View File

@@ -0,0 +1,116 @@
if polyglot#init#is_disabled(expand('<sfile>:p'), 'typescript', 'syntax/ts-common/keyword.vim')
finish
endif
"Import
syntax keyword typescriptImport from as
syntax keyword typescriptImport import
\ nextgroup=typescriptImportType,typescriptTypeBlock,typescriptDefaultImportName
\ skipwhite
syntax keyword typescriptImportType type
\ contained
syntax keyword typescriptExport export
\ nextgroup=typescriptExportType
\ skipwhite
syntax match typescriptExportType /\<type\s*{\@=/
\ contained skipwhite skipempty skipnl
syntax keyword typescriptModule namespace module
syntax keyword typescriptCastKeyword as satisfies
\ nextgroup=@typescriptType
\ skipwhite
syntax keyword typescriptVariable let var
\ nextgroup=@typescriptVariableDeclarations
\ skipwhite skipempty
syntax keyword typescriptVariable const
\ nextgroup=typescriptEnum,@typescriptVariableDeclarations
\ skipwhite skipempty
syntax keyword typescriptUsing using
\ nextgroup=@typescriptVariableDeclarations
\ skipwhite skipempty
syntax region typescriptEnum matchgroup=typescriptEnumKeyword start=/enum / end=/\ze{/
\ nextgroup=typescriptBlock
\ skipwhite
syntax keyword typescriptKeywordOp
\ contained in instanceof nextgroup=@typescriptValue
syntax keyword typescriptOperator delete new typeof void
\ nextgroup=@typescriptValue
\ skipwhite skipempty
syntax keyword typescriptForOperator contained in of
syntax keyword typescriptBoolean true false nextgroup=@typescriptSymbols skipwhite skipempty
syntax keyword typescriptMessage alert confirm prompt status
\ nextgroup=typescriptDotNotation,typescriptFuncCallArg
syntax keyword typescriptGlobal self top parent
\ nextgroup=@afterIdentifier
"Statement Keywords
syntax keyword typescriptConditional if else switch
\ nextgroup=typescriptConditionalParen
\ skipwhite skipempty skipnl
syntax keyword typescriptConditionalElse else
syntax keyword typescriptRepeat do while for nextgroup=typescriptLoopParen skipwhite skipempty
syntax keyword typescriptRepeat for nextgroup=typescriptLoopParen,typescriptAsyncFor skipwhite skipempty
syntax keyword typescriptBranch break continue containedin=typescriptBlock
syntax keyword typescriptCase case nextgroup=@typescriptPrimitive skipwhite containedin=typescriptBlock
syntax keyword typescriptDefault default containedin=typescriptBlock nextgroup=@typescriptValue,typescriptClassKeyword,typescriptInterfaceKeyword skipwhite oneline
syntax keyword typescriptStatementKeyword with
syntax keyword typescriptStatementKeyword yield skipwhite nextgroup=@typescriptValue containedin=typescriptBlock
syntax keyword typescriptTry try
syntax keyword typescriptExceptions catch throw finally
syntax keyword typescriptDebugger debugger
syntax keyword typescriptAsyncFor await nextgroup=typescriptLoopParen skipwhite skipempty contained
syntax region typescriptLoopParen contained matchgroup=typescriptParens
\ start=/(/ end=/)/
\ contains=typescriptVariable,typescriptForOperator,typescriptEndColons,@typescriptValue,@typescriptComments
\ nextgroup=typescriptBlock
\ skipwhite skipempty
syntax region typescriptConditionalParen contained matchgroup=typescriptParens
\ start=/(/ end=/)/
\ contains=@typescriptValue,@typescriptComments
\ nextgroup=typescriptBlock
\ skipwhite skipempty
syntax match typescriptEndColons /[;,]/ contained
syntax keyword typescriptAmbientDeclaration declare nextgroup=@typescriptAmbients
\ skipwhite skipempty
syntax cluster typescriptAmbients contains=
\ typescriptVariable,
\ typescriptFuncKeyword,
\ typescriptClassKeyword,
\ typescriptAbstract,
\ typescriptEnumKeyword,typescriptEnum,
\ typescriptModule
syntax keyword typescriptIdentifier arguments nextgroup=@afterIdentifier
syntax match typescriptDefaultImportName /\v\h\k*( |,)/
\ contained
\ nextgroup=typescriptTypeBlock
\ skipwhite skipempty
syntax region typescriptTypeBlock
\ matchgroup=typescriptBraces
\ start=/{/ end=/}/
\ contained
\ contains=typescriptIdentifierName,typescriptImportType
\ fold
"Program Keywords
exec 'syntax keyword typescriptNull null '.(exists('g:typescript_conceal_null') ? 'conceal cchar='.g:typescript_conceal_null : '').' nextgroup=@typescriptSymbols skipwhite skipempty'
exec 'syntax keyword typescriptNull undefined '.(exists('g:typescript_conceal_undefined') ? 'conceal cchar='.g:typescript_conceal_undefined : '').' nextgroup=@typescriptSymbols skipwhite skipempty'
"this
exec 'syntax keyword typescriptIdentifier this '.(exists('g:typescript_conceal_this') ? 'conceal cchar='.g:typescript_conceal_this : '').' nextgroup=@afterIdentifier'
exec 'syntax keyword typescriptIdentifier super '.(exists('g:typescript_conceal_super') ? 'conceal cchar='.g:typescript_conceal_super : '').' nextgroup=@afterIdentifier'
"JavaScript Prototype
exec 'syntax keyword typescriptPrototype prototype '.(exists('g:typescript_conceal_prototype') ? 'conceal cchar='.g:typescript_conceal_prototype : '').' nextgroup=@afterIdentifier'
exec 'syntax keyword typescriptStatementKeyword return '.(exists('g:typescript_conceal_return') ? 'conceal cchar='.g:typescript_conceal_return : '').' skipwhite contained nextgroup=@typescriptValue containedin=typescriptBlock'

View File

@@ -0,0 +1,58 @@
if polyglot#init#is_disabled(expand('<sfile>:p'), 'typescript', 'syntax/ts-common/literal.vim')
finish
endif
"Syntax in the JavaScript code
" String
syntax match typescriptASCII contained /\\\d\d\d/
syntax region typescriptTemplateSubstitution matchgroup=typescriptTemplateSB
\ start=/\${/ end=/}/
\ contains=@typescriptValue,typescriptCastKeyword
\ contained
syntax region typescriptString
\ start=+\z(["']\)+ skip=+\\\%(\z1\|$\)+ end=+\z1+ end=+$+
\ contains=typescriptSpecial,@Spell
\ nextgroup=@typescriptSymbols
\ skipwhite skipempty
\ extend
syntax match typescriptSpecial contained "\v\\%(x\x\x|u%(\x{4}|\{\x{1,6}})|c\u|.)"
" From pangloss/vim-javascript
" <https://github.com/pangloss/vim-javascript/blob/d6e137563c47fb59f26ed25d044c0c7532304f18/syntax/javascript.vim#L64-L72>
syntax region typescriptRegexpCharClass contained start=+\[+ skip=+\\.+ end=+\]+ contains=typescriptSpecial extend
syntax match typescriptRegexpBoundary contained "\v\c[$^]|\\b"
syntax match typescriptRegexpBackRef contained "\v\\[1-9]\d*"
syntax match typescriptRegexpQuantifier contained "\v[^\\]%([?*+]|\{\d+%(,\d*)?})\??"lc=1
syntax match typescriptRegexpOr contained "|"
syntax match typescriptRegexpMod contained "\v\(\?[:=!>]"lc=1
syntax region typescriptRegexpGroup contained start="[^\\]("lc=1 skip="\\.\|\[\(\\.\|[^]]\+\)\]" end=")" contains=typescriptRegexpCharClass,@typescriptRegexpSpecial keepend
syntax region typescriptRegexpString
\ start=+\%(\%(\<return\|\<typeof\|\_[^)\]'"[:blank:][:alnum:]_$]\)\s*\)\@<=/\ze[^*/]+ skip=+\\.\|\[[^]]\{1,}\]+ end=+/[gimyus]\{,6}+
\ contains=typescriptRegexpCharClass,typescriptRegexpGroup,@typescriptRegexpSpecial
\ oneline keepend extend
syntax cluster typescriptRegexpSpecial contains=typescriptSpecial,typescriptRegexpBoundary,typescriptRegexpBackRef,typescriptRegexpQuantifier,typescriptRegexpOr,typescriptRegexpMod
syntax region typescriptTemplate
\ start=/`/ skip=/\\\\\|\\`\|\n/ end=/`\|$/
\ contains=typescriptTemplateSubstitution,typescriptSpecial,@Spell
\ nextgroup=@typescriptSymbols
\ skipwhite skipempty
"Array
syntax region typescriptArray matchgroup=typescriptBraces
\ start=/\[/ end=/]/
\ contains=@typescriptValue,@typescriptComments,typescriptCastKeyword
\ nextgroup=@typescriptSymbols,typescriptDotNotation
\ skipwhite skipempty fold
" Number
syntax match typescriptNumber /\<0[bB][01][01_]*\>/ nextgroup=@typescriptSymbols skipwhite skipempty
syntax match typescriptNumber /\<0[oO][0-7][0-7_]*\>/ nextgroup=@typescriptSymbols skipwhite skipempty
syntax match typescriptNumber /\<0[xX][0-9a-fA-F][0-9a-fA-F_]*\>/ nextgroup=@typescriptSymbols skipwhite skipempty
syntax match typescriptNumber /\<\%(\d[0-9_]*\%(\.\d[0-9_]*\)\=\|\.\d[0-9_]*\)\%([eE][+-]\=\d[0-9_]*\)\=\>/
\ nextgroup=@typescriptSymbols skipwhite skipempty

View File

@@ -0,0 +1,53 @@
if polyglot#init#is_disabled(expand('<sfile>:p'), 'typescript', 'syntax/ts-common/members.vim')
finish
endif
syntax keyword typescriptConstructor contained constructor
\ nextgroup=@typescriptCallSignature
\ skipwhite skipempty
syntax cluster memberNextGroup contains=typescriptMemberOptionality,typescriptTypeAnnotation,@typescriptCallSignature
syntax match typescriptMember /#\?\K\k*/
\ nextgroup=@memberNextGroup
\ contained skipwhite
syntax match typescriptMethodAccessor contained /\v(get|set)\s\K/me=e-1
\ nextgroup=@typescriptMembers
syntax cluster typescriptPropertyMemberDeclaration contains=
\ typescriptClassStatic,
\ typescriptAccessibilityModifier,
\ typescriptReadonlyModifier,
\ typescriptAutoAccessor,
\ typescriptMethodAccessor,
\ @typescriptMembers
" \ typescriptMemberVariableDeclaration
syntax match typescriptMemberOptionality /?\|!/ contained
\ nextgroup=typescriptTypeAnnotation,@typescriptCallSignature
\ skipwhite skipempty
syntax cluster typescriptMembers contains=typescriptMember,typescriptStringMember,typescriptComputedMember
syntax keyword typescriptClassStatic static
\ nextgroup=@typescriptMembers,typescriptAsyncFuncKeyword,typescriptReadonlyModifier
\ skipwhite contained
syntax keyword typescriptAccessibilityModifier public private protected contained
syntax keyword typescriptReadonlyModifier readonly override contained
syntax keyword typescriptAutoAccessor accessor contained
syntax region typescriptStringMember contained
\ start=/\z(["']\)/ skip=/\\\\\|\\\z1\|\\\n/ end=/\z1/
\ nextgroup=@memberNextGroup
\ skipwhite skipempty
syntax region typescriptComputedMember contained matchgroup=typescriptProperty
\ start=/\[/rs=s+1 end=/]/
\ contains=@typescriptValue,typescriptMember,typescriptMappedIn,typescriptCastKeyword
\ nextgroup=@memberNextGroup
\ skipwhite skipempty

View File

@@ -0,0 +1,34 @@
if polyglot#init#is_disabled(expand('<sfile>:p'), 'typescript', 'syntax/ts-common/object.vim')
finish
endif
syntax region typescriptObjectLiteral matchgroup=typescriptBraces
\ start=/{/ end=/}/
\ contains=@typescriptComments,typescriptObjectLabel,typescriptStringProperty,typescriptComputedPropertyName,typescriptObjectAsyncKeyword,typescriptTernary,typescriptCastKeyword
\ fold contained
syntax keyword typescriptObjectAsyncKeyword async contained
syntax match typescriptObjectLabel contained /\k\+\_s*/
\ nextgroup=typescriptObjectColon,@typescriptCallImpl
\ skipwhite skipempty
syntax region typescriptStringProperty contained
\ start=/\z(["']\)/ skip=/\\\\\|\\\z1\|\\\n/ end=/\z1/
\ nextgroup=typescriptObjectColon,@typescriptCallImpl
\ skipwhite skipempty
" syntax region typescriptPropertyName contained start=/\z(["']\)/ skip=/\\\\\|\\\z1\|\\\n/ end=/\z1(/me=e-1 nextgroup=@typescriptCallSignature skipwhite skipempty oneline
syntax region typescriptComputedPropertyName contained matchgroup=typescriptBraces
\ start=/\[/rs=s+1 end=/]/
\ contains=@typescriptValue
\ nextgroup=typescriptObjectColon,@typescriptCallImpl
\ skipwhite skipempty
" syntax region typescriptComputedPropertyName contained matchgroup=typescriptPropertyName start=/\[/rs=s+1 end=/]\_s*:/he=e-1 contains=@typescriptValue nextgroup=@typescriptValue skipwhite skipempty
" syntax region typescriptComputedPropertyName contained matchgroup=typescriptPropertyName start=/\[/rs=s+1 end=/]\_s*(/me=e-1 contains=@typescriptValue nextgroup=@typescriptCallSignature skipwhite skipempty
" Value for object, statement for label statement
syntax match typescriptRestOrSpread /\.\.\./ contained
syntax match typescriptObjectSpread /\.\.\./ contained containedin=typescriptObjectLiteral,typescriptArray nextgroup=@typescriptValue
syntax match typescriptObjectColon contained /:/ nextgroup=@typescriptValue skipwhite skipempty

View File

@@ -0,0 +1,9 @@
if polyglot#init#is_disabled(expand('<sfile>:p'), 'typescript', 'syntax/ts-common/patch.vim')
finish
endif
" patch for generated code
syntax keyword typescriptGlobal Promise
\ nextgroup=typescriptGlobalPromiseDot,typescriptFuncCallArg,typescriptTypeArguments oneline
syntax keyword typescriptGlobal Map WeakMap
\ nextgroup=typescriptGlobalPromiseDot,typescriptFuncCallArg,typescriptTypeArguments oneline

View File

@@ -0,0 +1,35 @@
if polyglot#init#is_disabled(expand('<sfile>:p'), 'typescript', 'syntax/ts-common/reserved.vim')
finish
endif
syntax cluster typescriptStrings contains=typescriptProp,typescriptString,typescriptTemplate,@typescriptComments,typescriptDocComment,typescriptRegexpString,typescriptPropertyName
syntax cluster typescriptNoReserved contains=
\ @typescriptStrings,
\ @typescriptDocs,
\ @typescriptComments,
\ shellbang,
\ typescriptObjectLiteral,
\ typescriptObjectLabel,
\ typescriptClassBlock,
\ @typescriptType,
\ typescriptCall
"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#Keywords
syntax keyword typescriptReserved containedin=ALLBUT,@typescriptNoReserved break case catch const continue
syntax keyword typescriptReserved containedin=ALLBUT,@typescriptNoReserved debugger delete do else export
syntax keyword typescriptReserved containedin=ALLBUT,@typescriptNoReserved extends finally for if
"import,typescriptRegexpString,typescriptPropertyName
syntax keyword typescriptReserved containedin=ALLBUT,@typescriptNoReserved in instanceof let new return super
syntax keyword typescriptReserved containedin=ALLBUT,@typescriptNoReserved static switch throw try typeof
syntax keyword typescriptReserved containedin=ALLBUT,@typescriptNoReserved void while with yield
syntax keyword typescriptReserved containedin=ALLBUT,@typescriptNoReserved implements package protected
syntax keyword typescriptReserved containedin=ALLBUT,@typescriptNoReserved interface private public readonly abstract
syntax keyword typescriptReserved containedin=ALLBUT,@typescriptNoReserved byte char double final float goto int
syntax keyword typescriptReserved containedin=ALLBUT,@typescriptNoReserved long native short synchronized transient
syntax keyword typescriptReserved containedin=ALLBUT,@typescriptNoReserved volatile
syntax keyword typescriptReserved containedin=ALLBUT,@typescriptNoReserved class
syntax keyword typescriptReserved containedin=ALLBUT,@typescriptNoReserved var
syntax keyword typescriptReserved containedin=ALLBUT,@typescriptNoReserved function

View File

@@ -0,0 +1,44 @@
if polyglot#init#is_disabled(expand('<sfile>:p'), 'typescript', 'syntax/ts-common/symbols.vim')
finish
endif
" + - ^ ~
syntax match typescriptUnaryOp /[+\-~!]/
\ nextgroup=@typescriptValue
\ skipwhite
syntax region typescriptTernary matchgroup=typescriptTernaryOp start=/?[.?]\@!/ end=/:/ contained contains=@typescriptValue,@typescriptComments nextgroup=@typescriptValue skipwhite skipempty
syntax match typescriptAssign /=/ nextgroup=@typescriptValue
\ skipwhite skipempty
" 2: ==, ===
syntax match typescriptBinaryOp contained /===\?/ nextgroup=@typescriptValue skipwhite skipempty
" 6: >>>=, >>>, >>=, >>, >=, >
syntax match typescriptBinaryOp contained />\(>>=\|>>\|>=\|>\|=\)\?/ nextgroup=@typescriptValue skipwhite skipempty
" 4: <<=, <<, <=, <
syntax match typescriptBinaryOp contained /<\(<=\|<\|=\)\?/ nextgroup=@typescriptValue skipwhite skipempty
" 3: ||, |=, |, ||=
syntax match typescriptBinaryOp contained /||\?=\?/ nextgroup=@typescriptValue skipwhite skipempty
" 4: &&, &=, &, &&=
syntax match typescriptBinaryOp contained /&&\?=\?/ nextgroup=@typescriptValue skipwhite skipempty
" 2: ??, ??=
syntax match typescriptBinaryOp contained /??=\?/ nextgroup=@typescriptValue skipwhite skipempty
" 2: *=, *
syntax match typescriptBinaryOp contained /\*=\?/ nextgroup=@typescriptValue skipwhite skipempty
" 2: %=, %
syntax match typescriptBinaryOp contained /%=\?/ nextgroup=@typescriptValue skipwhite skipempty
" 2: /=, /
syntax match typescriptBinaryOp contained +/\(=\|[^\*/]\@=\)+ nextgroup=@typescriptValue skipwhite skipempty
syntax match typescriptBinaryOp contained /!==\?/ nextgroup=@typescriptValue skipwhite skipempty
" 2: !=, !==
syntax match typescriptBinaryOp contained /+\(+\|=\)\?/ nextgroup=@typescriptValue skipwhite skipempty
" 3: +, ++, +=
syntax match typescriptBinaryOp contained /-\(-\|=\)\?/ nextgroup=@typescriptValue skipwhite skipempty
" 3: -, --, -=
" exponentiation operator
" 2: **, **=
syntax match typescriptBinaryOp contained /\*\*=\?/ nextgroup=@typescriptValue
syntax cluster typescriptSymbols contains=typescriptBinaryOp,typescriptKeywordOp,typescriptTernary,typescriptAssign,typescriptCastKeyword

217
syntax/ts-common/type.vim Normal file
View File

@@ -0,0 +1,217 @@
if polyglot#init#is_disabled(expand('<sfile>:p'), 'typescript', 'syntax/ts-common/type.vim')
finish
endif
" Types
syntax match typescriptOptionalMark /?/ contained
syntax cluster typescriptTypeParameterCluster contains=
\ typescriptTypeParameter,
\ typescriptGenericDefault
syntax region typescriptTypeParameters matchgroup=typescriptTypeBrackets
\ start=/</ end=/>/
\ contains=@typescriptTypeParameterCluster
\ contained
syntax match typescriptTypeParameter /\K\k*/
\ nextgroup=typescriptConstraint
\ contained skipwhite skipnl
syntax keyword typescriptConstraint extends
\ nextgroup=@typescriptType
\ contained skipwhite skipnl
syntax match typescriptGenericDefault /=/
\ nextgroup=@typescriptType
\ contained skipwhite
"><
" class A extend B<T> {} // ClassBlock
" func<T>() // FuncCallArg
syntax region typescriptTypeArguments matchgroup=typescriptTypeBrackets
\ start=/\></ end=/>/
\ contains=@typescriptType
\ nextgroup=typescriptFuncCallArg,@typescriptTypeOperator
\ contained skipwhite
syntax cluster typescriptType contains=
\ @typescriptPrimaryType,
\ typescriptUnion,
\ @typescriptFunctionType,
\ typescriptConstructorType
" array type: A[]
" type indexing A['key']
syntax region typescriptTypeBracket contained
\ start=/\[/ end=/\]/
\ contains=typescriptString,typescriptNumber
\ nextgroup=@typescriptTypeOperator
\ skipwhite skipempty
syntax cluster typescriptPrimaryType contains=
\ typescriptParenthesizedType,
\ typescriptPredefinedType,
\ typescriptTypeReference,
\ typescriptObjectType,
\ typescriptTupleType,
\ typescriptTypeQuery,
\ typescriptStringLiteralType,
\ typescriptTemplateLiteralType,
\ typescriptReadonlyArrayKeyword,
\ typescriptAssertType
syntax region typescriptStringLiteralType contained
\ start=/\z(["']\)/ skip=/\\\\\|\\\z1\|\\\n/ end=/\z1\|$/
\ nextgroup=typescriptUnion
\ skipwhite skipempty
syntax region typescriptTemplateLiteralType contained
\ start=/`/ skip=/\\\\\|\\`\|\n/ end=/`\|$/
\ contains=typescriptTemplateSubstitutionType
\ nextgroup=typescriptTypeOperator
\ skipwhite skipempty
syntax region typescriptTemplateSubstitutionType matchgroup=typescriptTemplateSB
\ start=/\${/ end=/}/
\ contains=@typescriptType
\ contained
syntax region typescriptParenthesizedType matchgroup=typescriptParens
\ start=/(/ end=/)/
\ contains=@typescriptType
\ nextgroup=@typescriptTypeOperator
\ contained skipwhite skipempty fold
syntax match typescriptTypeReference /\K\k*\(\.\K\k*\)*/
\ nextgroup=typescriptTypeArguments,@typescriptTypeOperator,typescriptUserDefinedType
\ skipwhite contained skipempty
syntax keyword typescriptPredefinedType any number boolean string void never undefined null object unknown
\ nextgroup=@typescriptTypeOperator
\ contained skipwhite skipempty
syntax match typescriptPredefinedType /unique symbol/
\ nextgroup=@typescriptTypeOperator
\ contained skipwhite skipempty
syntax region typescriptObjectType matchgroup=typescriptBraces
\ start=/{/ end=/}/
\ contains=@typescriptTypeMember,typescriptEndColons,@typescriptComments,typescriptAccessibilityModifier,typescriptReadonlyModifier
\ nextgroup=@typescriptTypeOperator
\ contained skipwhite skipnl fold
syntax cluster typescriptTypeMember contains=
\ @typescriptCallSignature,
\ typescriptConstructSignature,
\ typescriptIndexSignature,
\ @typescriptMembers
syntax match typescriptTupleLable /\K\k*?\?:/
\ contained
syntax region typescriptTupleType matchgroup=typescriptBraces
\ start=/\[/ end=/\]/
\ contains=@typescriptType,@typescriptComments,typescriptRestOrSpread,typescriptTupleLable
\ contained skipwhite
syntax cluster typescriptTypeOperator
\ contains=typescriptUnion,typescriptTypeBracket,typescriptConstraint,typescriptConditionalType
syntax match typescriptUnion /|\|&/ contained nextgroup=@typescriptPrimaryType skipwhite skipempty
syntax match typescriptConditionalType /?\|:/ contained nextgroup=@typescriptPrimaryType skipwhite skipempty
syntax cluster typescriptFunctionType contains=typescriptGenericFunc,typescriptFuncType
syntax region typescriptGenericFunc matchgroup=typescriptTypeBrackets
\ start=/</ end=/>/
\ contains=typescriptTypeParameter
\ nextgroup=typescriptFuncType
\ containedin=typescriptFunctionType
\ contained skipwhite skipnl
syntax region typescriptFuncType matchgroup=typescriptParens
\ start=/(\(\k\+:\|)\)\@=/ end=/)\s*=>/me=e-2
\ contains=@typescriptParameterList
\ nextgroup=typescriptFuncTypeArrow
\ contained skipwhite skipnl oneline
syntax match typescriptFuncTypeArrow /=>/
\ nextgroup=@typescriptType
\ containedin=typescriptFuncType
\ contained skipwhite skipnl
syntax keyword typescriptConstructorType new
\ nextgroup=@typescriptFunctionType
\ contained skipwhite skipnl
syntax keyword typescriptUserDefinedType is
\ contained nextgroup=@typescriptType skipwhite skipempty
syntax keyword typescriptTypeQuery typeof keyof
\ nextgroup=typescriptTypeReference
\ contained skipwhite skipnl
syntax keyword typescriptAssertType asserts
\ nextgroup=typescriptTypeReference
\ contained skipwhite skipnl
syntax cluster typescriptCallSignature contains=typescriptGenericCall,typescriptCall
syntax region typescriptGenericCall matchgroup=typescriptTypeBrackets
\ start=/</ end=/>/
\ contains=typescriptTypeParameter
\ nextgroup=typescriptCall
\ contained skipwhite skipnl
syntax region typescriptCall matchgroup=typescriptParens
\ start=/(/ end=/)/
\ contains=typescriptDecorator,@typescriptParameterList,@typescriptComments
\ nextgroup=typescriptTypeAnnotation,typescriptBlock
\ contained skipwhite skipnl
syntax match typescriptTypeAnnotation /:/
\ nextgroup=@typescriptType
\ contained skipwhite skipnl
syntax cluster typescriptParameterList contains=
\ typescriptTypeAnnotation,
\ typescriptAccessibilityModifier,
\ typescriptReadonlyModifier,
\ typescriptOptionalMark,
\ typescriptRestOrSpread,
\ typescriptFuncComma,
\ typescriptDefaultParam
syntax match typescriptFuncComma /,/ contained
syntax match typescriptDefaultParam /=/
\ nextgroup=@typescriptValue
\ contained skipwhite
syntax keyword typescriptConstructSignature new
\ nextgroup=@typescriptCallSignature
\ contained skipwhite
syntax region typescriptIndexSignature matchgroup=typescriptBraces
\ start=/\[/ end=/\]/
\ contains=typescriptPredefinedType,typescriptMappedIn,typescriptString
\ nextgroup=typescriptTypeAnnotation
\ contained skipwhite oneline
syntax keyword typescriptMappedIn in
\ nextgroup=@typescriptType
\ contained skipwhite skipnl skipempty
syntax keyword typescriptAliasKeyword type
\ nextgroup=typescriptAliasDeclaration
\ skipwhite skipnl skipempty
syntax region typescriptAliasDeclaration matchgroup=typescriptUnion
\ start=/ / end=/=/
\ nextgroup=@typescriptType
\ contains=typescriptConstraint,typescriptTypeParameters
\ contained skipwhite skipempty
syntax keyword typescriptReadonlyArrayKeyword readonly
\ nextgroup=@typescriptPrimaryType
\ skipwhite