Last active
August 29, 2015 14:15
-
-
Save h14i/749c2ececc13973b2865 to your computer and use it in GitHub Desktop.
Setup project-local tsc path
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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