Quramy / tsuquyomi

A Vim plugin for TypeScript
http://www.vim.org/scripts/script.php?script_id=5151
1.39k stars 72 forks source link

TypeScript version check fails if bash options are specified #129

Open nerfologist opened 7 years ago

nerfologist commented 7 years ago

Hi, I just ran into the following problem.

Test setup

This is my environment:

OS: macOS Sierra 10.12.4 (16E195)
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Apr 11 2017 14:34:53)
MacOS X (unix) version
Included patches: 1-525
Compiled by Homebrew

I have a test typescript file test.ts containing a typescript compilation error:

var aString: string = 1

And this is my test .vimrc

set nocompatible
filetype off

" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()

" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'

" typescript
Plugin 'Quramy/tsuquyomi'

" All of your Plugins must be added before the following line
call vundle#end()
filetype plugin indent on

" enable bash4 globstar in forked bash shells
" set shell+=\ -O\ globstar

It correctly shows the following error in location window: greeter.ts|1 col 5 error| Type '1' is not assignable to type 'string'.

The problem

Now, if I uncomment the following line: set shell+=\ -O\ globstar

and open the file again, I get the following error: [Tsuquyomi] Your TypeScript version is invalid

I did my best to trace this error to the following section in tsuquyomi/autoload/tsuquyomi/config.vim:116-123:

function! s:system(cmd)
  let out = ''
  let job = job_start([&shell, &shellcmdflag, a:cmd], {'out_cb': {ch,msg->[execute("let out .= msg"), out]}, 'out_mode': 'raw'})
  while job_status(job) == 'run'
    sleep 10m
  endwhile
  return out
endfunction

Turns out that out is an empty string in this case. I suspect that it has something to do with the job_start([&shell, ...])call when options are specified. Unfortunately I don't know enough vimscript to provide a PR.

Thanks for your awesome plugin, HTH

Quramy commented 7 years ago

Thanks for your report, I'll try to reproduce and provides some workarounds.