Comments (38)
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.
from ale.
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.
from ale.
For future reference: To use the new direct interface to tsserver and get similar functionality to tsuquyomi, use
let g:ale_linters = {
\ 'typescript': ['tsserver'],
\}```
from ale.
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.
from ale.
Great!
tslint
Style checking
Just needs stdin wrapper, pretty straightforward.
Out of curiosity, what's the rationale behind requiring linters to accept stdin?
tsc
Syntax and type checking
tsc is the official typescript compiler, however it's really slow (takes 2 seconds for a hello world).
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.
tsuquyomi
This plugin wraps TSServer and makes it really easy to use.
However, this uses vimproc.vim, an async task runner, to populate the quickfix list.
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.
Do we just use tsuquyomi and accept that people need to install an async task runner when they're already using vim 8? And do we try and integrate changes into their repo so that we can feed its output directly into ALE?
On the other hand, directly wrapping TSServer also seems like too much work that shouldn't belong here.
Maybe we should fork tsuquyomi to use vim8 async?
from ale.
I suppose we'd need to rewrite what tsuquyomi
does to use the new Vim 8 functionality. It probably used vimproc because the new async functions weren't available at the time.
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.
from ale.
I just remembered that I actually already wrote such a Bash wrapper script. I forgot that I did that.
from ale.
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)
from ale.
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.
from ale.
Ah, that's a great idea. It does have a switch for that. I'll try using that and seeing if perf is acceptable
from ale.
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 .
from ale.
Let me know how you get on. Sounds good to me. 👍
from ale.
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.
from ale.
@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.
from ale.
Sounds good to me!
from ale.
the problem with tsuquomy that it sends requests to tsserver synchronously: https://github.com/Quramy/tsuquyomi/blob/master/autoload/tsuquyomi/tsClient.vim#L335
from ale.
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.
from ale.
@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
from ale.
If NeoVim doesn't support socket connections, then we'll have to make it a Vim 8 only feature.
from ale.
from ale.
@w0rp https://github.com/Microsoft/TypeScript/wiki/Standalone-Server-%28tsserver%29#message-format
so, no need to use http, but implementing whole protocol might be too difficult just for type checking...
from ale.
Can't we have just a simple wrapping of tsc right now? As a first step, I mean...
from ale.
Yeah, we could do. Feel free to give it a go.
from ale.
@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 :(
from ale.
Look at Neomakes implementation for tsc if it is applicable, runs fast on both Windows and OSX.
Handles tsconfig just fine.
from ale.
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
from ale.
See https://github.com/neomake/neomake/blob/master/autoload/neomake/makers/ft/typescript.vim for a "simple" tsc config.
from ale.
@blueyed it doesn't work right, because tsc
doesn't look for tsconfig.json
, when file is specified...
from ale.
@mkusher
There is no file specified in this case (append_file
).
from ale.
@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
from ale.
Not compiling the whole project breaks the tsc checkers because the compiler can't resolve imports, know about type definitions etc without any context.
from ale.
@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
from ale.
But you'll loose the context given by the tsconfig file. Those settings are crucial.
from ale.
@JohanBjoerklund yep, I've created simple package that would do the trick https://github.com/mkusher/ts-checker
but it's still slow comparing with tsserver
from ale.
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).
from ale.
That isn't necessary. tsserver
support is enabled by default for typescript
files.
from ale.
I didn't see tsserver
output, since the eslint
output was on top. tsserver
is better, though.
from ale.
There is also https://github.com/autozimu/LanguageClient-neovim which also supports tsserver, but also other features (like multilanguage refactorings)
from ale.
Related Issues (20)
- ALE linting .tsx as .ts files when using Biome
- [Biome] Linter not usable
- Should/could ALE pass --no-fix argument to ruff when linting (to override project configuration)? HOT 5
- ALEHover text not appearing in floating preview HOT 1
- Cannot use ALE in MacVim when the file is opened via the right-click context menu or the File > Open dialog in MacVim HOT 2
- error loading shared lib: libicui18n.so.73 HOT 1
- json linting with jq doesn't report errors correctly
- On Windows 11, shell=pwsh/powershell continues breaking ALE lint HOT 1
- `write-good` plugin need make separate files that only have text
- cspell option “-c config.yaml” not work
- `sqlfluff` does not work in Neovim, throws an error when trying to lint an opened file HOT 1
- Signs cannot be customized HOT 5
- ALEFix with clangtidy not updating the buffer HOT 1
- clang++ command not getting correct include paths
- error highlights entire function
- Add support for pymarkdown
- Strange syntax highlighting behavior with ALE on Neovim HOT 1
- ALE ruff format shows error: "Unidentified byte: Loading .env environment variables..."
- ALE support linter group HOT 3
- Incorrect eslint project root when using nested node_modules HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ale.