- Notifications
You must be signed in to change notification settings - Fork144
Typescript syntax files for Vim
leafgarland/typescript-vim
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
NOTE: This Typescript syntax was created before Typescript's 1.0 release, more than a decade ago. I hope ithas been helpful but there are now other options available. Vim has includedTypescript syntax for some years,which receives more frequent updates at its ownrepository.Neovim can also use atreesitter grammar for highlighting.
Syntax file and other settings forTypeScript. Thesyntax file was originally from this 2012blogpost.
CheckoutTsuquyomi for omni-completionand other features for TypeScript editing.
From Vim 8 onward, the plugin can be installed as simply as (Unix/Mac):
git clone https://github.com/leafgarland/typescript-vim.git ~/.vim/pack/typescript/start/typescript-vimOn Windows/Powershell, use the following:
git clone https://github.com/leafgarland/typescript-vim.git $home/vimfiles/pack/typescript/start/typescript-vimFor older versions of Vim, the simplest way to install is via a Vim add-in manager such asPlug,Vundle orPathogen.
See theInstallation Wiki
git clone https://github.com/leafgarland/typescript-vim.git ~/.vim/bundle/typescript-vimIf you want to install manually then you need to copy the files from thisrepository into your vim path, see the vim docs for:helpruntimepathfor more information. This might be as simple as copying the files anddirectories to~/.vim/ but it depends on your Vim install and operatingsystem.
Once the files are installed the syntax highlighting and other settings will beautomatically enabled anytime you edit a.ts file.
This plugin includes a custom indenter (based onpangloss/vim-javascript'sindenter),it works pretty well but there are cases where it fails. If these bother you orwant to use other indent settings you can disable it by setting a flag in your.vimrc:
letg:typescript_indent_disable=1
If you want the indenter to automatically indent chained method calls as you type.
something.foo().bar();
Then add something likesetlocal indentkeys+=0. to your.vimrc, see:help 'indentkeys' in vim for more information.
If you use the= operator to re-indent code it will always indentchained method calls - this can be disabled by changing the regex theindent script uses to identify indented lines. In this case removing '.'from the regex means that it wont indent lines starting with '.'. Note,this is not ideal as the regex may change making your setting out of date.
letg:typescript_opfirst='\%([<>=,?^%|*/&]\|\([-:+]\)\1\@!\|!=\|in\%(stanceof\)\=\>\)'
This plugin contains compiler settings to setmakeprg anderrorformat.The compiler settings enable you to call thetsc compiler directly from Vimand display any errors or warnings in Vim's QuickFix window.
To run the compiler, enter:make, this will runtsc against the last savedversion of your currently edited file.
The default formakeprg istsc $* %. You can enter other compiler options into your:makecommand line and they will be inserted in place of$*.
There are options to change the compiler name and to insert default options.
letg:typescript_compiler_binary='tsc'letg:typescript_compiler_options=''
These options will be passed to the binary as command arguments. For example,ifg:typescript_compiler_binary = 'tsc' andg:typescript_compiler_options = '--lib es6',l:makeprg will be:tsc --lib es6 $* %.
You can completely override this plugin's compiler settings with something likethis in your.vimrc, where you can set makeprg to whatever you want.
autocmdFileTypetypescript :setmakeprg=tsc
Note, this plugin's compiler settings are not used by Syntastic which has its ownway of changing the options. Seehttps://github.com/scrooloose/syntastic#faqargs.
You can use something like this in your.vimrc to make the QuickFixwindow automatically appear if:make has any errors.
autocmdQuickFixCmdPost[^l]* nestedcwindowautocmdQuickFixCmdPostl* nestedlwindow
Syntax highlighting for TypeScript can be customized by following variables.
g:typescript_ignore_typescriptdoc: When this variable is defined, doccomments will not behighlighted.g:typescript_ignore_browserwords: When this variable is set to1, browser API names such aswindowordocumentwill not be highlighted. (default to0)
About
Typescript syntax files for Vim
Topics
Resources
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Uh oh!
There was an error while loading.Please reload this page.
