-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add checkers for TypeScript #20
Comments
I'm totally in favour of this. I think I'm generally in favour of adding more support for linting everything. I'll probably start using TypeScript personally soon enough. |
Great! tslintStyle checking tscSyntax and type checking TypeScript also comes with a tool called TSServer which uses some caching magic to run the same checks extremely fast, at the cost of a few hundred ms at startup. Aside from checking, it also adds intellisense autocomplete. This is what's used in Sublime/VS Code/WebStorm. tsuquyomiThis plugin wraps TSServer and makes it really easy to use. Syntastic's approach to this problem was to add a syntastic checker in the tsuquyomi repo itself and add an option to disable tsuquyomi's use of the quickfix list. I'm not sure how to approach this. |
I suppose we'd need to rewrite what The linters need to accept stdin input because we need to be able to send the text for files which are open without first saving the files back to disk. The linting is applied by sending the contents of the text buffer directly to a given program. I might write a Bash wrapper script will could be used for sending input to most programs. Then eventually I might add a Batch wrapper script for Windows, which will be... interesting. |
I just remembered that I actually already wrote such a Bash wrapper script. I forgot that I did that. |
I'd like to still keep track of this, because TSLint only handles style checks but not compile/type checks which are the main selling point of TypeScript. For the latter one needs to still install vimproc,tsuquyomi then use :w to check. (Even though vimproc provides async, it just means that vim doesn't freeze when makeprg is run instead of lint-as-you-type) |
I'll re-open this one then. I wonder if TypeScript has something like switch for checking semantics without producing output. That's what I set up for D with the reference D compiler. |
Ah, that's a great idea. It does have a switch for that. I'll try using that and seeing if perf is acceptable |
Unfortunately disabling output had no effect on linting speed, still too slow. On the bright side, I noticed that not many files in the Tsuquyomi project use vimproc, and they use it for job control. I'll try forking it and making it work with vim8 jobs intstead . |
Let me know how you get on. Sounds good to me. 👍 |
You know, maybe my machine is just a lot faster than yours, but for me, the hello world takes 0.8 seconds (slow, but not ungodly), and a large TS project takes 3 seconds. I don't really see an issue with tsc as long as compile times are around a second for a file. |
For TypeScript, we need to connect to the server for checking TypeScript. The tsuquyomi) plugin somehow handles this. It might be best to submit pull requests to support using job control instead of vimproc in that plugin, and another pull request adding an ALE linter. We would need to support socket connections, in addition to commands. I'm not sure if NeoVim can handle that. |
@neersighted It is indeed. hello world with tsc takes 2.3 seconds for me. However on the same machine, Tsuquyomi runs and gives me the same errors in 0.2 seconds. I think an improvement of that scale is definitely worth shooting for. Besides, from the experience of myself and a few others, nobody will use vim and TypeScript without Tsuquyomi as it provdes many other features including omnicomplete, refactoring, jump to definition, show usages, YouCompleteMe integration, Unite.vim integration, etc. So the only real solution IMO would be to submit PRs or make a fork. I don't have the time currently, but I may give it a try in the coming few months. |
Sounds good to me! |
the problem with tsuquomy that it sends requests to tsserver synchronously: https://github.com/Quramy/tsuquyomi/blob/master/autoload/tsuquyomi/tsClient.vim#L335 |
We might just have to connect to the TypeScript server ourselves. The only problem is, I find it hard to find any documentation describing 1. How to start the TypeScript server. 2. Which ports to connect on. 3. What the message format is. |
@w0rp this info we can get from tsuquyomi, but does neovim have same api for async sockets as vim8? And what format will be used for tsc linter? I think we need to specify viml function that accepts callback |
If NeoVim doesn't support socket connections, then we'll have to make it a Vim 8 only feature. |
@w0rp https://github.com/Microsoft/TypeScript/wiki/Standalone-Server-%28tsserver%29#message-format |
Can't we have just a simple wrapping of tsc right now? As a first step, I mean... |
Yeah, we could do. Feel free to give it a go. |
@pinver I've made simple ts script that runs compiler check instead of using tsc, because tsc ignores tsconfig if the file passed to it. The problem is that it may take 5 seconds for script to finish :( |
Look at Neomakes implementation for tsc if it is applicable, runs fast on both Windows and OSX. |
I've added a quick change to the tslint linter so it looks for the nearest tslint.json config. Let me know what you think. Full request for the change: #198 |
See https://github.com/neomake/neomake/blob/master/autoload/neomake/makers/ft/typescript.vim for a "simple" tsc config. |
@blueyed it doesn't work right, because |
@mkusher |
@blueyed oh, I see. Yeah, it should work, but it might be very slow to compile and type check whole project instead of one file |
Not compiling the whole project breaks the tsc checkers because the compiler can't resolve imports, know about type definitions etc without any context. |
@JohanBjoerklund compiler doesn't need whole project, it can just compile file and all it's deps, like it would do if you just specify file |
But you'll loose the context given by the tsconfig file. Those settings are crucial. |
@JohanBjoerklund yep, I've created simple package that would do the trick https://github.com/mkusher/ts-checker |
I'm going to forego the tsuquyomi integration in favour of implementing a Language Server Protocol client and a TypeScript linter which uses it, in the next milestone. |
I'm a bit late to the game, but... I have a plugin similar to tsuquyomi called vim-tss that uses the native neovim job API for async. That might be worth looking at. Also note that tsserver doesn't itself implement the Language Server Protocol (microsoft/TypeScript#11274). |
For future reference: To use the new direct interface to tsserver and get similar functionality to tsuquyomi, use
|
That isn't necessary. |
I didn't see |
There is also https://github.com/autozimu/LanguageClient-neovim which also supports tsserver, but also other features (like multilanguage refactorings) |
Specifically, tsc (or maybe tsuquyomi) and tslint
Status
The text was updated successfully, but these errors were encountered: