typescript-tools.nvim icon indicating copy to clipboard operation
typescript-tools.nvim copied to clipboard

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

Open NullVoxPopuli opened this issue 1 year ago • 5 comments

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?

NullVoxPopuli avatar Oct 30 '24 13:10 NullVoxPopuli

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.

pyrho avatar Oct 31 '24 12:10 pyrho

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

mikewuu avatar Dec 05 '24 12:12 mikewuu

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

KostkaBrukowa avatar Dec 05 '24 13:12 KostkaBrukowa

When I setup typescript-tools.nvim plugin, why the buffer was attached to both ts_ls and typescript-tools? and I can't even filter out some diagnostics.

winkee01 avatar Mar 03 '25 22:03 winkee01

When I setup typescript-tools.nvim plugin, why the buffer was attached to both ts_ls and typescript-tools? and I can't even filter out some diagnostics.

If you set up with mason lspconfig 2.0+, when you install ts_ls through Mason, the Mason-lspconfig will automatically call vim.lsp.enable(ts_ls) which trigger ts_ls for you.

Simple solution is just to exclude ts_ls from mason-lspconfig

nguyenanhhao221 avatar Jun 15 '25 15:06 nguyenanhhao221