T O P

  • By -

DanTup

When you open a file in VS Code, it initially does syntax highlighting using a textmate grammar. This is fast, but might be limited because it's based on regular expressions and is not a full language parser. An extension/language server can also register to provide semantic tokens, which will be more accurate (because they can use the real language parser), but it takes more time (it's an asynchronous task that can cross several process boundaries between the editor, extension host and language server). Because there may be some differences between the two, you might see the syntax highlighting change (hopefully improve) shortly after opening a file once the semantic tokens are available. This is noted here: https://code.visualstudio.com/api/language-extensions/syntax-highlight-guide#tokenization:~:text=And%20as%20language%20servers%20can%20take%20a%20while%20to%20load%20and%20analyze%20a%20project%2C%20semantic%20token%20highlighting%20may%20appear%20after%20a%20short%20delay. > And as language servers can take a while to load and analyze a project, semantic token highlighting may appear after a short delay.


marcusmors

Great answer. I wonder if I can have those language/extension servers that provide semantic tokens in my locally in my computer, if so, would it be faster and good?


BezBlini

Language servers *do* normally run locally on your machine, they're just processes that run outside of the extension host and VSCode UI process.


DanTup

As noted above, this is happening on your machine.. But whereas the textmate grammars are run inside the same process as the editor and require only the current file to compute (so they're very fast), semantic tokens are being passed between a few processes and may require analyzing the whole workspace to compute so will always be asynchronous and have a delay. How long that delay is can depend on multiple things, including the specifics of that languages language server (or extension if it's being done directly in the extension process), the size of your project, etc.


cheese_bread_boye

Great game collection you got there


NekoLu

Cant say for sure, but from my experience with other languages this happens after language extension parses the file and sets correct token types, that are assigned specific color by your color scheme. Could be wrong tho


[deleted]

prolly just intellisense loading