Skip to content
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

Reading the "How it works" section, I'm still uncertain what's different from the regular ts lsp? #306

Open
NullVoxPopuli opened this issue Oct 30, 2024 · 3 comments

Comments

@NullVoxPopuli
Copy link

Was reading: https://github.com/pmizio/typescript-tools.nvim?tab=readme-ov-file#-how-it-works

and I'm still not clear why or how typescript-tools is better than ts_ls.

Any additional insights would be greatly appreciated <3

I have run in to all the problems the README has described for large monorepos (slow, etc), but I don't see how typescript-tools does anything different?

@pyrho
Copy link

pyrho commented Oct 31, 2024

I am by no means an authoritative source on this matter, so grains of salts required; but my understanding is that typescript-tools removes a middle man, eliminating a costly I/O step.

NeoVim                       ts_ls                     Tsserver Instance
┌────────────────┐           ┌────────────────┐            ┌────────────────┐
│                │           │                │            │                │
│                │           │                │            │                │
│                │           │                │            │                │
│                │           │                │            │                │
│                │           │       T        │            │                │
│                │           │       r        │            │                │
│                │           │       a        │            │                │
│                │           │       n        │            │                │
│                │           │       s        │            │                │
│                │           │       l        │            │                │
│                │           │       a        │            │                │
│                ├───────────▶       t        │────────────▶                │
│                │           │       i        │            │                │
│                ◀───────────┤       o        │◀───────────┤                │
│                │  Request/ │       n        │  Request/  │                │
│                │  Response │                │  Response  │                │
│                │     IO    │                │     IO     │                │
│                │           │                │            │                │
└────────────────┘           └────────────────┘            └────────────────┘

The translation done by ts_ls (to translate LSP request to and from tsserver's own dialect) is handled directly in lua within neovim by typescript-tools.

Someone please correct me if my assumptions are wrong.

@mikewuu
Copy link

mikewuu commented Dec 5, 2024

coc does translation too, and that's supposedly faster than everything. Translation might not be the only factor here.

It might have to do with not blocking the process. This is a separate plugin and has access to nvim apis. Specifically, the handlers are wrapped in vim.schedule to avoid blocking the event loop. coc achieves the same thing by being a separate process. ts_ls, vtsls are just cli programs the lsp talks to directly, so it might not be as efficient.

Another possibility is the lua plugin is being pre-compiled and runs faster than node apps. 🤷‍♂️

Maybe the ultimate TS lsp would be:

nvim -> lua plugin -> LSP translator in rust/go -> tsserver

@KostkaBrukowa
Copy link
Collaborator

The ultimate TS LSP would be nvim -> tsserver but we've got what we've got :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants