-
I've implemented several LSP servers. In all of them, I never define a TextMate file. As of LSP 3.16, semantic tokens supports the colorization of text, and it's fast. But, when I go to create the "hello-world" from template (see https://langium.org/docs/getting-started/ for instructions), a TM file is generated ( |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hi @kaby76,
Yes, Langium supports LSP and semantic tokens in particular. Langium's grammar DSL is written in Langium (and uses semantic tokens), so you can see the Langium source code for an example use case:
As for the TextMate file: this is not a replacement for semantic tokens, but rather an extra way to have highlighting. We generate also a Monarch file (for instance, a Monarch file for the statemachine example, generation of which can be enabled in |
Beta Was this translation helpful? Give feedback.
-
In addition to what @pluralia already said, the TextMate grammar has a bit of an advantage, as it doesn't require a call to the language server in order to display the correct text styling. It can apply the token style instantly, while the semantic token styling will always have a short delay. For vscode, the optimal solution is usually to mix TextMate generated tokens and semantic tokens from the LSP for token styling. For example, Microsoft does the same for TypeScript. |
Beta Was this translation helpful? Give feedback.
Hi @kaby76,
Yes, Langium supports LSP and semantic tokens in particular. Langium's grammar DSL is written in Langium (and uses semantic tokens), so you can see the Langium source code for an example use case:
SemanticTokensProvider
(for that it's enough to extendAbstractSemanticTokenProvider
like Langium does it here)<your-dsl-name>-module.ts
(like here)As for the TextMate file: this is not a replacement for semantic tokens, but rather an extra way to have highlighting. We generate also a Monarch file (for instance, a Monarch file for the statemachine example, generation of which can be enabled in
lang…