Skip to content

Instantly share code, notes, and snippets.

@h14i
Last active August 29, 2015 14:15
Show Gist options
  • Save h14i/749c2ececc13973b2865 to your computer and use it in GitHub Desktop.
Save h14i/749c2ececc13973b2865 to your computer and use it in GitHub Desktop.
Setup project-local tsc path
augroup typescript-tscpath
autocmd!
autocmd BufNewFile,BufRead *.ts call TSCPath()
augroup END
function! TSCPath() "{{{
if !exists('g:typescript_compiler_binary')
" try get local tsc path
let tsc_path = split(system('npm ls -s --parseable typescript'), '\n')[-1]
if !executable(tsc_path . '/bin/tsc')
" try get global tsc path
let tsc_path = split(system('npm ls -sg --parseable typescript'), '\n')[-1]
endif
if tsc_path != '' && executable(tsc_path . '/bin/tsc')
let g:typescript_compiler_binary_dir = tsc_path . '/bin/tsc'
endif
endif
autocmd! typescript-tscpath
endfunction "}}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment