mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Merge pull request #13037 from janlazo/runtime-typescript
runtime: sync typescript runtime files with Vim
This commit is contained in:
commit
07fde6c394
29
runtime/compiler/ts-node.vim
Normal file
29
runtime/compiler/ts-node.vim
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
" Vim compiler file
|
||||||
|
" Compiler: TypeScript Runner
|
||||||
|
" Maintainer: Doug Kearns <dougkearns@gmail.com>
|
||||||
|
" Last Change: 2020 Feb 10
|
||||||
|
|
||||||
|
if exists("current_compiler")
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
let current_compiler = "node"
|
||||||
|
|
||||||
|
if exists(":CompilerSet") != 2 " older Vim always used :setlocal
|
||||||
|
command -nargs=* CompilerSet setlocal <args>
|
||||||
|
endif
|
||||||
|
|
||||||
|
let s:cpo_save = &cpo
|
||||||
|
set cpo&vim
|
||||||
|
|
||||||
|
" CompilerSet makeprg=npx\ ts-node
|
||||||
|
|
||||||
|
CompilerSet makeprg=ts-node
|
||||||
|
CompilerSet errorformat=%f\ %#(%l\\,%c):\ %trror\ TS%n:\ %m,
|
||||||
|
\%E%f:%l,
|
||||||
|
\%+Z%\\w%\\+Error:\ %.%#,
|
||||||
|
\%C%p^%\\+,
|
||||||
|
\%C%.%#,
|
||||||
|
\%-G%.%#
|
||||||
|
|
||||||
|
let &cpo = s:cpo_save
|
||||||
|
unlet s:cpo_save
|
26
runtime/compiler/tsc.vim
Normal file
26
runtime/compiler/tsc.vim
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
" Vim compiler file
|
||||||
|
" Compiler: TypeScript Compiler
|
||||||
|
" Maintainer: Doug Kearns <dougkearns@gmail.com>
|
||||||
|
" Last Change: 2020 Feb 10
|
||||||
|
|
||||||
|
if exists("current_compiler")
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
let current_compiler = "tsc"
|
||||||
|
|
||||||
|
if exists(":CompilerSet") != 2 " older Vim always used :setlocal
|
||||||
|
command -nargs=* CompilerSet setlocal <args>
|
||||||
|
endif
|
||||||
|
|
||||||
|
let s:cpo_save = &cpo
|
||||||
|
set cpo&vim
|
||||||
|
|
||||||
|
" CompilerSet makeprg=npx\ tsc
|
||||||
|
|
||||||
|
CompilerSet makeprg=tsc
|
||||||
|
CompilerSet errorformat=%f\ %#(%l\\,%c):\ %trror\ TS%n:\ %m,
|
||||||
|
\%trror\ TS%n:\ %m,
|
||||||
|
\%-G%.%#
|
||||||
|
|
||||||
|
let &cpo = s:cpo_save
|
||||||
|
unlet s:cpo_save
|
39
runtime/ftplugin/typescript.vim
Normal file
39
runtime/ftplugin/typescript.vim
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
" Vim filetype plugin file
|
||||||
|
" Language: TypeScript
|
||||||
|
" Maintainer: Doug Kearns <dougkearns@gmail.com>
|
||||||
|
" Last Change: 2019 Aug 30
|
||||||
|
|
||||||
|
if exists("b:did_ftplugin")
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
let b:did_ftplugin = 1
|
||||||
|
|
||||||
|
let s:cpo_save = &cpo
|
||||||
|
set cpo-=C
|
||||||
|
|
||||||
|
" Set 'formatoptions' to break comment lines but not other lines,
|
||||||
|
" and insert the comment leader when hitting <CR> or using "o".
|
||||||
|
setlocal formatoptions-=t formatoptions+=croql
|
||||||
|
|
||||||
|
" Set 'comments' to format dashed lists in comments.
|
||||||
|
setlocal comments=sO:*\ -,mO:*\ \ ,exO:*/,s1:/*,mb:*,ex:*/,://
|
||||||
|
|
||||||
|
setlocal commentstring=//%s
|
||||||
|
|
||||||
|
setlocal suffixesadd+=.ts,.d.ts,.tsx,.js,.jsx,.cjs,.mjs
|
||||||
|
|
||||||
|
" Change the :browse e filter to primarily show TypeScript-related files.
|
||||||
|
if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")
|
||||||
|
let b:browsefilter="TypeScript Files (*.ts)\t*.ts\n" .
|
||||||
|
\ "TypeScript Declaration Files (*.d.ts)\t*.d.ts\n" .
|
||||||
|
\ "TSX Files (*.tsx)\t*.tsx\n" .
|
||||||
|
\ "JavaScript Files (*.js)\t*.js\n" .
|
||||||
|
\ "JavaScript Modules (*.es, *.cjs, *.mjs)\t*.es;*.cjs;*.mjs\n" .
|
||||||
|
\ "JSON Files (*.json)\t*.json\n" .
|
||||||
|
\ "All Files (*.*)\t*.*\n"
|
||||||
|
endif
|
||||||
|
|
||||||
|
let b:undo_ftplugin = "setl fo< com< cms< sua< | unlet! b:browsefilter"
|
||||||
|
|
||||||
|
let &cpo = s:cpo_save
|
||||||
|
unlet s:cpo_save
|
33
runtime/ftplugin/typescriptreact.vim
Normal file
33
runtime/ftplugin/typescriptreact.vim
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
" Vim filetype plugin file
|
||||||
|
" Language: TypeScript React
|
||||||
|
" Maintainer: Doug Kearns <dougkearns@gmail.com>
|
||||||
|
" Last Change: 2020 Aug 09
|
||||||
|
|
||||||
|
let s:match_words = ""
|
||||||
|
let s:undo_ftplugin = ""
|
||||||
|
|
||||||
|
runtime! ftplugin/typescript.vim
|
||||||
|
|
||||||
|
let s:cpo_save = &cpo
|
||||||
|
set cpo-=C
|
||||||
|
|
||||||
|
if exists("b:match_words")
|
||||||
|
let s:match_words = b:match_words
|
||||||
|
endif
|
||||||
|
if exists("b:undo_ftplugin")
|
||||||
|
let s:undo_ftplugin = b:undo_ftplugin
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Matchit configuration
|
||||||
|
if exists("loaded_matchit")
|
||||||
|
let b:match_ignorecase = 0
|
||||||
|
let b:match_words = s:match_words .
|
||||||
|
\ '<:>,' .
|
||||||
|
\ '<\@<=\([^ \t>/]\+\)\%(\s\+[^>]*\%([^/]>\|$\)\|>\|$\):<\@<=/\1>,' .
|
||||||
|
\ '<\@<=\%([^ \t>/]\+\)\%(\s\+[^/>]*\|$\):/>'
|
||||||
|
endif
|
||||||
|
|
||||||
|
let b:undo_ftplugin = "unlet! b:match_words b:match_ignorecase | " . s:undo_ftplugin
|
||||||
|
|
||||||
|
let &cpo = s:cpo_save
|
||||||
|
unlet s:cpo_save
|
@ -1,7 +1,7 @@
|
|||||||
" Vim indent file
|
" Vim indent file
|
||||||
" Language: TypeScript
|
" Language: TypeScript
|
||||||
" Maintainer: See https://github.com/HerringtonDarkholme/yats.vim
|
" Maintainer: See https://github.com/HerringtonDarkholme/yats.vim
|
||||||
" Last Change: 2019 Jun 06
|
" Last Change: 2019 Oct 18
|
||||||
" Acknowledgement: Based off of vim-ruby maintained by Nikolai Weibull http://vim-ruby.rubyforge.org
|
" Acknowledgement: Based off of vim-ruby maintained by Nikolai Weibull http://vim-ruby.rubyforge.org
|
||||||
|
|
||||||
" 0. Initialization {{{1
|
" 0. Initialization {{{1
|
||||||
@ -442,7 +442,7 @@ let &cpo = s:cpo_save
|
|||||||
unlet s:cpo_save
|
unlet s:cpo_save
|
||||||
|
|
||||||
function! Fixedgq(lnum, count)
|
function! Fixedgq(lnum, count)
|
||||||
let l:tw = &tw ? &tw : 80;
|
let l:tw = &tw ? &tw : 80
|
||||||
|
|
||||||
let l:count = a:count
|
let l:count = a:count
|
||||||
let l:first_char = indent(a:lnum) + 1
|
let l:first_char = indent(a:lnum) + 1
|
||||||
|
File diff suppressed because it is too large
Load Diff
2067
runtime/syntax/typescriptcommon.vim
Normal file
2067
runtime/syntax/typescriptcommon.vim
Normal file
File diff suppressed because it is too large
Load Diff
160
runtime/syntax/typescriptreact.vim
Normal file
160
runtime/syntax/typescriptreact.vim
Normal file
@ -0,0 +1,160 @@
|
|||||||
|
" Vim syntax file
|
||||||
|
" Language: TypeScript with React (JSX)
|
||||||
|
" Maintainer: Bram Moolenaar
|
||||||
|
" Last Change: 2019 Nov 30
|
||||||
|
" Based On: Herrington Darkholme's yats.vim
|
||||||
|
" Changes: See https:github.com/HerringtonDarkholme/yats.vim
|
||||||
|
" Credits: See yats.vim on github
|
||||||
|
|
||||||
|
if !exists("main_syntax")
|
||||||
|
if exists("b:current_syntax")
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
let main_syntax = 'typescriptreact'
|
||||||
|
endif
|
||||||
|
|
||||||
|
let s:cpo_save = &cpo
|
||||||
|
set cpo&vim
|
||||||
|
|
||||||
|
syntax region tsxTag
|
||||||
|
\ start=+<\([^/!?<>="':]\+\)\@=+
|
||||||
|
\ skip=+</[^ /!?<>"']\+>+
|
||||||
|
\ end=+/\@<!>+
|
||||||
|
\ end=+\(/>\)\@=+
|
||||||
|
\ contained
|
||||||
|
\ contains=tsxTagName,tsxIntrinsicTagName,tsxAttrib,tsxEscJs,
|
||||||
|
\tsxCloseString,@tsxComment
|
||||||
|
|
||||||
|
syntax match tsxTag /<>/ contained
|
||||||
|
|
||||||
|
|
||||||
|
" <tag></tag>
|
||||||
|
" s~~~~~~~~~e
|
||||||
|
" and self close tag
|
||||||
|
" <tag/>
|
||||||
|
" s~~~~e
|
||||||
|
" A big start regexp borrowed from https://git.io/vDyxc
|
||||||
|
syntax region tsxRegion
|
||||||
|
\ start=+<\_s*\z([a-zA-Z1-9\$_-]\+\(\.\k\+\)*\)+
|
||||||
|
\ skip=+<!--\_.\{-}-->+
|
||||||
|
\ end=+</\_s*\z1>+
|
||||||
|
\ matchgroup=tsxCloseString end=+/>+
|
||||||
|
\ fold
|
||||||
|
\ contains=tsxRegion,tsxCloseString,tsxCloseTag,tsxTag,tsxCommentInvalid,tsxFragment,tsxEscJs,@Spell
|
||||||
|
\ keepend
|
||||||
|
\ extend
|
||||||
|
|
||||||
|
" <> </>
|
||||||
|
" s~~~~~~e
|
||||||
|
" A big start regexp borrowed from https://git.io/vDyxc
|
||||||
|
syntax region tsxFragment
|
||||||
|
\ start=+\(\((\|{\|}\|\[\|,\|&&\|||\|?\|:\|=\|=>\|\Wreturn\|^return\|\Wdefault\|^\|>\)\_s*\)\@<=<>+
|
||||||
|
\ skip=+<!--\_.\{-}-->+
|
||||||
|
\ end=+</>+
|
||||||
|
\ fold
|
||||||
|
\ contains=tsxRegion,tsxCloseString,tsxCloseTag,tsxTag,tsxCommentInvalid,tsxFragment,tsxEscJs,@Spell
|
||||||
|
\ keepend
|
||||||
|
\ extend
|
||||||
|
|
||||||
|
" </tag>
|
||||||
|
" ~~~~~~
|
||||||
|
syntax match tsxCloseTag
|
||||||
|
\ +</\_s*[^/!?<>"']\+>+
|
||||||
|
\ contained
|
||||||
|
\ contains=tsxTagName,tsxIntrinsicTagName
|
||||||
|
|
||||||
|
syntax match tsxCloseTag +</>+ contained
|
||||||
|
|
||||||
|
syntax match tsxCloseString
|
||||||
|
\ +/>+
|
||||||
|
\ contained
|
||||||
|
|
||||||
|
" <!-- -->
|
||||||
|
" ~~~~~~~~
|
||||||
|
syntax match tsxCommentInvalid /<!--\_.\{-}-->/ display
|
||||||
|
|
||||||
|
syntax region tsxBlockComment
|
||||||
|
\ contained
|
||||||
|
\ start="/\*"
|
||||||
|
\ end="\*/"
|
||||||
|
|
||||||
|
syntax match tsxLineComment
|
||||||
|
\ "//.*$"
|
||||||
|
\ contained
|
||||||
|
\ display
|
||||||
|
|
||||||
|
syntax cluster tsxComment contains=tsxBlockComment,tsxLineComment
|
||||||
|
|
||||||
|
syntax match tsxEntity "&[^; \t]*;" contains=tsxEntityPunct
|
||||||
|
syntax match tsxEntityPunct contained "[&.;]"
|
||||||
|
|
||||||
|
" <tag key={this.props.key}>
|
||||||
|
" ~~~
|
||||||
|
syntax match tsxTagName
|
||||||
|
\ +[</]\_s*[^/!?<>"'* ]\++hs=s+1
|
||||||
|
\ contained
|
||||||
|
\ nextgroup=tsxAttrib
|
||||||
|
\ skipwhite
|
||||||
|
\ display
|
||||||
|
syntax match tsxIntrinsicTagName
|
||||||
|
\ +[</]\_s*[a-z1-9-]\++hs=s+1
|
||||||
|
\ contained
|
||||||
|
\ nextgroup=tsxAttrib
|
||||||
|
\ skipwhite
|
||||||
|
\ display
|
||||||
|
|
||||||
|
" <tag key={this.props.key}>
|
||||||
|
" ~~~
|
||||||
|
syntax match tsxAttrib
|
||||||
|
\ +[a-zA-Z_][-0-9a-zA-Z_]*+
|
||||||
|
\ nextgroup=tsxEqual skipwhite
|
||||||
|
\ contained
|
||||||
|
\ display
|
||||||
|
|
||||||
|
" <tag id="sample">
|
||||||
|
" ~
|
||||||
|
syntax match tsxEqual +=+ display contained
|
||||||
|
\ nextgroup=tsxString skipwhite
|
||||||
|
|
||||||
|
" <tag id="sample">
|
||||||
|
" s~~~~~~e
|
||||||
|
syntax region tsxString contained start=+"+ end=+"+ contains=tsxEntity,@Spell display
|
||||||
|
|
||||||
|
" <tag key={this.props.key}>
|
||||||
|
" s~~~~~~~~~~~~~~e
|
||||||
|
syntax region tsxEscJs
|
||||||
|
\ contained
|
||||||
|
\ contains=@typescriptValue,@tsxComment
|
||||||
|
\ matchgroup=typescriptBraces
|
||||||
|
\ start=+{+
|
||||||
|
\ end=+}+
|
||||||
|
\ extend
|
||||||
|
|
||||||
|
|
||||||
|
"""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||||
|
" Source the part common with typescriptreact.vim
|
||||||
|
source <sfile>:h/typescriptcommon.vim
|
||||||
|
|
||||||
|
|
||||||
|
syntax cluster typescriptExpression add=tsxRegion,tsxFragment
|
||||||
|
|
||||||
|
hi def link tsxTag htmlTag
|
||||||
|
hi def link tsxTagName Function
|
||||||
|
hi def link tsxIntrinsicTagName htmlTagName
|
||||||
|
hi def link tsxString String
|
||||||
|
hi def link tsxNameSpace Function
|
||||||
|
hi def link tsxCommentInvalid Error
|
||||||
|
hi def link tsxBlockComment Comment
|
||||||
|
hi def link tsxLineComment Comment
|
||||||
|
hi def link tsxAttrib Type
|
||||||
|
hi def link tsxEscJs tsxEscapeJs
|
||||||
|
hi def link tsxCloseTag htmlTag
|
||||||
|
hi def link tsxCloseString Identifier
|
||||||
|
|
||||||
|
let b:current_syntax = "typescriptreact"
|
||||||
|
if main_syntax == 'typescriptreact'
|
||||||
|
unlet main_syntax
|
||||||
|
endif
|
||||||
|
|
||||||
|
let &cpo = s:cpo_save
|
||||||
|
unlet s:cpo_save
|
Loading…
Reference in New Issue
Block a user