mirror of
https://github.com/sheerun/vim-polyglot.git
synced 2025-11-10 12:33:51 -05:00
53 lines
2.0 KiB
VimL
53 lines
2.0 KiB
VimL
let s:base = expand("<sfile>:h:h")
|
|
let Filter = { _, v -> stridx(v, s:base) == -1 && stridx(v, $VIMRUNTIME) == -1 && v !~ "after" }
|
|
let files = filter(globpath(&rtp, 'syntax/basic/literal.vim', 1, 1), Filter)
|
|
if len(files) > 0
|
|
exec 'source ' . files[0]
|
|
finish
|
|
endif
|
|
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'typescript') == -1
|
|
|
|
"Syntax in the JavaScript code
|
|
|
|
" String
|
|
syntax match typescriptASCII contained /\\\d\d\d/
|
|
|
|
syntax region typescriptTemplateSubstitution matchgroup=typescriptTemplateSB
|
|
\ start=/\${/ end=/}/
|
|
\ contains=@typescriptValue
|
|
\ contained
|
|
|
|
|
|
syntax region typescriptString
|
|
\ start=+\z(["']\)+ skip=+\\\%(\z1\|$\)+ end=+\z1+ end=+$+
|
|
\ contains=typescriptSpecial,@Spell
|
|
\ extend
|
|
|
|
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=+/[gimuy]\{0,5\}\s*$+ end=+/[gimuy]\{0,5\}\s*[;.,)\]}:]+me=e-1 nextgroup=typescriptDotNotation oneline
|
|
|
|
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
|
|
\ 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
|
|
|
|
endif
|