TypeScript completion in Vim
One of the main advantages of using static types is that you get much better support from your tools. I recently got TypeScript auto-completion working in vim and I’m documenting how to do it here.
Demo:
1. Install TSS
git clone https://github.com/clausreinke/typescript-tools.git
cd typescript-tools
git checkout testing_ts1.4
sudo npm install -g
2. Install Vim Plugin
I’m using Vundle to manage my plugins.
Bundle "icholy/typescript-tools.git"
au BufRead,BufNewFile *.ts setlocal filetype=typescript
3. Install TSD
sudo npm install tsd@next -g
4. Create Project
mkdir project
cd project
tsd init
tsd install jquery --save
tsd install angularjs --save
5. Create tsconfig.json
{
"compilerOptions": {
"target": "es5",
"noImplicitAny": false,
},
"files": [
"typings/tsd.d.ts",
"all.ts", "your.ts",
"other.ts", "files.ts"
]
}
6. Start TSS in vim
Make sure you’re cwd is somewhere in the directory containing tsconfig.json
:TSSstart
You might get some errors, but it should still work.
7. (Optional) Making it work with YouCompleteMe
if !exists("g:ycm_semantic_triggers")
let g:ycm_semantic_triggers = {}
endif
let g:ycm_semantic_triggers['typescript'] = ['.']
set completeopt-=preview