4 ms·
> And it [syntax highlighting] basically doesn’t fit nicely in the CRDT model at all, as that requires the ability to resolve arbitrarily divergent edits betwee
by bhl 6y ago
> And it [syntax highlighting] basically doesn’t fit nicely in the CRDT model at all, as that requires the ability to resolve arbitrarily divergent edits between the different processes (imagine that one goes offline for a bit, types a bit, then the language server comes back online and applies indentation).
What's a rationale for having syntax highlighting server-side as opposed to client-side? I'm working on side project that uses ProseMirror and CRDTs through yjs, and the idea of having a server for syntax highlighting for editable text never occurred to me.
> Even so, xray was a bit of a wake-up call for me. It was evidence that the vision I had set out for xi was not quite compelling enough that people would want to join forces.
I think in hindsight this was a virtue. If you look at the xray project, it died after the Microsoft acquisition of Github: https://github.com/atom-archive/xray/issues/177 https://github.com/atom-archive/xray/issues/177. By not combining projects, it allowed for redundancy.
- saagarjha 6y agoYour server generally has a better idea about the language than you do, presumably.
- bhl 6y agoI would only think that's the case when the language of the file you're editing is unknown, so you would have to do some server-side analysis of the entire file and make an educated guess. For example, https://github.com/github/linguist https://github.com/github/linguist. But if the language is known in advance, then you could send the grammar rules to the client.
- saagarjha 6y agoA server also means it still works when the language is not simple enough to condense into simple grammar rules :)
- raphlinus 6y agoSo, just syntax highlighting is not compelling to move out to a server. But part of my idea is that if you have async to hide server latency, so it's not slowing down typing, maybe you can do a much deeper analysis than just surface syntax. Right now you get basically instant coloring and then much slower but more accurate feedback that's generally comparable to an incremental recompile. I was thinking that a language server might be able to give you quick feedback on some aspects of your program before having to do all of it. Perhaps an even better motivation is indentation. When I use editors with regex-based indentation (the norm), I'm regularly annoyed when it gets it wrong. Being able to budget a few milliseconds or tends of milliseconds to do indentation that exactly matches what rustfmt or gofmt would recommend would be worth it, imho.
- jakear 6y agoVS Code’s semantic tokens are a similar concept: an initial client side pass using a tmGrammar, then a language-server provided set of refinements. https://code.visualstudio.com/api/language-extensions/semantic-highlight-guide https://code.visualstudio.com/api/language-extensions/semant...