in large files sematic highlighting is extremely slow. like when I define a variable and it takes a couple seconds to get highlighted. (By the way I am on WSL Ubuntu)
Hey, semantic highlighting in big files works through LSP. The language server has to parse the whole file to produce tokens, and VS Code also applies a debounce of about 300 to 2000 ms after each change. WSL adds extra IPC latency between the editor and the language server. This is inherited VS Code behavior, not Cursor-specific.
What you can try:
Disable semantic highlighting полностью, or let the theme decide, in settings.json:
Then highlighting will come only from the TextMate grammar, which is faster but less accurate.
Check if an extension is slowing things down. Run cursor --disable-extensions in a terminal and compare.
Let me know what language those files are. For some languages, like TS in huge projects, you can tune the language server settings.
If the issue still happens after this, share the language, the rough file size in lines or KB, and the list of active extensions, and we can dig deeper.
Would not it be better if it cached the whole file instead of parsing it everytime we add new lines? It should only highlight the new lines and not index the whole file
That’s a fair question, but there’s a catch. Semantic highlighting depends on the context of the whole file, not just the new line. When you add a variable, the language server has to recompute references, types, and scope across the file, because the new line can affect tokens elsewhere, like if you renamed a symbol or added an import.
Most language servers already do incremental parsing internally, so they don’t re-parse the file from scratch every time. But semantic analysis still needs to walk the AST. If highlighting only updated the new lines, you’d get inconsistent colors. For example, a new reference to an existing symbol wouldn’t get the right highlight without full context.
TextMate grammar, which you get with "editor.semanticHighlighting.enabled": false, works differently. It uses regex per line with no context. That’s why it’s faster but less accurate. If speed matters more than accuracy in big files, that’s a valid trade-off.
What language are the files where you’re seeing this? For some, like TS, you can tune the language server settings to reduce the load.