This commit is contained in:
Adam Stankiewicz
2022-10-14 17:40:10 +02:00
parent 38282d5838
commit bc8a81d359
74 changed files with 1217 additions and 775 deletions

View File

@@ -5,7 +5,7 @@ endif
"Import
syntax keyword typescriptImport from as
syntax keyword typescriptImport import
\ nextgroup=typescriptImportType
\ nextgroup=typescriptImportType,typescriptTypeBlock,typescriptDefaultImportName
\ skipwhite
syntax keyword typescriptImportType type
\ contained
@@ -17,11 +17,10 @@ syntax match typescriptExportType /\<type\s*{\@=/
syntax keyword typescriptModule namespace module
syntax keyword typescriptCastKeyword as
syntax keyword typescriptCastKeyword as satisfies
\ nextgroup=@typescriptType
\ skipwhite
syntax keyword typescriptVariable let var
\ nextgroup=@typescriptVariableDeclarations
\ skipwhite skipempty
@@ -90,6 +89,17 @@ 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
exec 'syntax keyword typescriptNull null '.(exists('g:typescript_conceal_null') ? 'conceal cchar='.g:typescript_conceal_null : '').' nextgroup=@typescriptSymbols skipwhite skipempty'

View File

@@ -22,9 +22,20 @@ syntax region typescriptString
syntax match typescriptSpecial contained "\v\\%(x\x\x|u%(\x{4}|\{\x{1,6}})|c\u|.)"
" From vim runtime
" <https://github.com/vim/vim/blob/master/runtime/syntax/javascript.vim#L48>
syntax region typescriptRegexpString start=+/[^/*]+me=e-1 skip=+\\\\\|\\/+ end=+/[gimsuy]\{0,5\}\s*$+ end=+/[gimsuy]\{0,5\}\s*[;.,)\]}:]+me=e-1 nextgroup=typescriptDotNotation oneline
" 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=/`\|$/