Vim Typescript Autocomplete
In this post I will be logging how I got autocomplete for typescript in vim.
In short, I installed pathogen with a bunch of plugins and scoured github issues pages so you don't have to.
On debian/ubuntu, you need vim-nox package in order to satisfy the lua dependency of neocomplete.vim.
First install pathogen (for everything else)
mkdir -p ~/.vim/autoload ~/.vim/bundle && \ curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim
Then install vimproc for tsuquyomi
mkdir -p ~/.vim/bundle git clone https://github.com/Shougo/vimproc.vim.git ~/.vim/bundle/vimproc.vim pushd ~/.vim/bundle/vimproc.vim make popd
Now install tsuquyomi
git clone https://github.com/Quramy/tsuquyomi.git ~/.vim/bundle/tsuquyomi
Install neocomplete
git clone https://github.com/Shougo/neocomplete.vim ~/.vim/bundle/neocomplete
Now set them up in ~/.vimrc (tsuquyomi needs to find tsserver)
" make pathogen work execute pathogen#infect() " typescript omnicomplete let g:tsuquyomi_use_dev_node_module=2 let g:tsuquyomi_tsserver_path='/home/nurettin/npm-global/bin/tsserver' autocmd FileType typescript set omnifunc=tsuquyomi#complete " neocomplete start with a dot let g:neocomplete#enable_at_startup = 1 if !exists('g:neocomplete#force_omni_input_patterns') let g:neocomplete#force_omni_input_patterns = {} endif let g:neocomplete#force_omni_input_patterns.typescript = '[^. *\t]\.\w*\|\h\w*::' "neocomplete tab complete inoremap <expr><tab> pumvisible() ? "\<c-n>" : \ <sid>check_back_space() ? "\<tab>" : \ neocomplete#start_manual_complete() function! s:check_back_space() "{{{ let col = col('.') - 1 return !col || getline('.')[col - 1] =~ '\s' endfunction"}}} filetype plugin on
Hopefully that will get you started.
Addendum:
After a bit of usage I started getting an error message:Cannot compile external modules unless the --module flag is provided
In order to avoid tsserver --module flag errors, you need to create a tsconfig.json file that specifies which files are modules.
{ "compilerOptions": { "module": "commonjs" }, "files": ["MyModule1.ts"] }













