vim-patch:66d8d28: runtime(typescript): Add syntax support for defer and arbitrary module identifiers

closes: vim/vim#17911

66d8d286cd

Co-authored-by: rhysd <lin90162@yahoo.co.jp>
This commit is contained in:
Christian Clason
2025-08-08 10:01:56 +02:00
committed by Christian Clason
parent 62f2b10db3
commit ffeb334da0

View File

@@ -2,6 +2,7 @@
" Language: TypeScript and TypeScriptReact
" Maintainer: Herrington Darkholme
" Last Change: 2024 May 24
" 2025 Aug 05 support for new TypeScript syntaxes
" Based On: Herrington Darkholme's yats.vim
" Changes: See https://github.com/HerringtonDarkholme/yats.vim
" Credits: See yats.vim on github
@@ -11,7 +12,6 @@ if &cpo =~ 'C'
set cpo&vim
endif
" NOTE: this results in accurate highlighting, but can be slow.
syntax sync fromstart
@@ -240,10 +240,22 @@ syntax cluster typescriptSymbols contains=typescriptBinaryOp,types
"Import
syntax keyword typescriptImport from as
syntax keyword typescriptImport import
\ nextgroup=typescriptImportType,typescriptTypeBlock,typescriptDefaultImportName
\ nextgroup=typescriptImportType,typescriptImportBlock,typescriptDefaultImportName,typescriptImportDefer
\ skipwhite
syntax keyword typescriptImportType type
\ contained
syntax match typescriptDefaultImportName /\v\h\k*( |,)/
\ contained
\ nextgroup=typescriptImportBlock
\ skipwhite skipempty
syntax match typescriptImportDefer /\<defer\%(\s\+\*\)\@=/
\ contained
syntax region typescriptImportBlock
\ matchgroup=typescriptBraces
\ start=/{/ end=/}/
\ contained
\ contains=typescriptIdentifierName,typescriptImportType,typescriptString
\ fold
syntax keyword typescriptExport export
\ nextgroup=typescriptExportType
\ skipwhite
@@ -329,21 +341,11 @@ syntax cluster typescriptAmbients contains=
\ 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
syntax keyword typescriptNull null undefined nextgroup=@typescriptSymbols skipwhite skipempty
syntax keyword typescriptIdentifier this super prototype nextgroup=@afterIdentifier
syntax keyword typescriptIdentifier this super nextgroup=@afterIdentifier
syntax keyword typescriptPrototype prototype nextgroup=@afterIdentifier
syntax keyword typescriptStatementKeyword return skipwhite contained nextgroup=@typescriptValue containedin=typescriptBlock
"Syntax coloring for Node.js shebang line
@@ -2029,7 +2031,7 @@ hi def link typescriptCase Conditional
hi def link typescriptDefault typescriptCase
hi def link typescriptBranch Conditional
hi def link typescriptIdentifier Structure
hi def link typescriptVariable Identifier
hi def link typescriptVariable Keyword
hi def link typescriptUsing Identifier
hi def link typescriptDestructureVariable PreProc
hi def link typescriptEnumKeyword Identifier
@@ -2037,8 +2039,8 @@ hi def link typescriptRepeat Repeat
hi def link typescriptForOperator Repeat
hi def link typescriptStatementKeyword Statement
hi def link typescriptMessage Keyword
hi def link typescriptOperator Identifier
hi def link typescriptKeywordOp Identifier
hi def link typescriptOperator Operator
hi def link typescriptKeywordOp Operator
hi def link typescriptCastKeyword Special
hi def link typescriptType Type
hi def link typescriptNull Boolean
@@ -2049,14 +2051,15 @@ hi def link typescriptDestructureLabel Function
hi def link typescriptLabel Label
hi def link typescriptTupleLable Label
hi def link typescriptStringProperty String
hi def link typescriptImport Special
hi def link typescriptImportType Special
hi def link typescriptAmbientDeclaration Special
hi def link typescriptExport Special
hi def link typescriptExportType Special
hi def link typescriptModule Special
hi def link typescriptTry Special
hi def link typescriptExceptions Special
hi def link typescriptImport Keyword
hi def link typescriptImportType Keyword
hi def link typescriptImportDefer Keyword
hi def link typescriptAmbientDeclaration Keyword
hi def link typescriptExport Keyword
hi def link typescriptExportType Keyword
hi def link typescriptModule Keyword
hi def link typescriptTry Exception
hi def link typescriptExceptions Exception
hi def link typescriptMember Function
hi def link typescriptMethodAccessor Operator
@@ -2076,7 +2079,7 @@ hi def link typescriptClassKeyword Keyword
hi def link typescriptClassExtends Keyword
hi def link typescriptAbstract Special
hi def link typescriptClassStatic StorageClass
hi def link typescriptReadonlyModifier Keyword
hi def link typescriptReadonlyModifier StorageClass
hi def link typescriptInterfaceKeyword Keyword
hi def link typescriptInterfaceExtends Keyword
hi def link typescriptInterfaceName Function
@@ -2107,7 +2110,7 @@ hi def link typescriptConstructor Keyword
hi def link typescriptDecorator Special
hi def link typescriptAssertType Keyword
hi link typeScript NONE
hi def link typeScript NONE
if exists('s:cpo_save')
let &cpo = s:cpo_save