Hacker News new | ask | show | jobs
by EdiX 3264 days ago
A separate server has also some advantages: (1) it's not going to crash your editor, and (2) it opens up the possibility of keeping the language server running outside of the editor and available to other tools.

Yes, serialization and communication has a lot of extra cost compared to a function call but consider that (1) the request rate is limited by user typing speed, which means around 10 requests per second tops, low enough that it won't matter, especially compared to running a type checker, (2) all the calls in LSP can take a very long time to complete, you won't be able to turn this protocol into blocking API calls that you do from the UI loop, because of this.

Even with a plugin you would need to run into a separate thread (or possibly threads) and cancel requests after a timeout.

That said, LSP is a terrible protocol. They chose to represent all offset in terms of UTF-16 (!) encoding units, which is truly retarded since most editors won't be reading UTF-16 files nor will they be representing them internally as UTF-16.

2 comments

You can also have state and caching and such within the server so the client can afford not thinking about that as well
> They chose to represent all offset in terms of UTF-16

Wow, yeah, that's pretty terrible.