Extend or customize syntax highlighting #604
-
I only started using this yesterday so I may have not stumbled on it. Is there a way to customize or extend the generated syntax highlighting? I'd prefer to not have everything go under "keyword.control". I know I could add semantic highlighting. do a embedded language or injection. I tried injection but I'm new to using that feature of vscode extensions. My use case is having 2 different styles of comments. Comment belongs to the type it is being referred to while a note should be ignored. terminal COMMENT: /\/\*[\s\S]*\*\//
hidden terminal NOTE: /\/\/*[\s\S]*?\*\//; This results in anything within |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Hi @EDKarlsson, the generated textMate syntax highlighting file is basically just a starting help for new grammars. Anyone who wants more fine-grained control over their syntactical highlighting should deactivate the Regarding your comments: I'm pretty sure that this style of commenting will lead to a lot of problems down the line. Your
I think this is (*drum roll*) out of scope for Langium. Our grammar language is already complicated enough as it is, and syntax highlighting can be easily done manually, so I don't really see a reason to include this into the grammar language. |
Beta Was this translation helpful? Give feedback.
-
That works as well. I couldn't find any documentation on deactivating the tmLanguage generation. Thanks for answering my question! I did try it and it does not overwrite the NOTE terminal. Unfortunately I do not have control of the grammar. This is a fun side project implementing SysML v2. I got decently far with my first attempt using textX (https://github.com/textX/textX) but it doesn't have any concept of fragments and rules started becoming unwieldy just to avoid creating an element representation of a rule |
Beta Was this translation helpful? Give feedback.
Hi @EDKarlsson, the generated textMate syntax highlighting file is basically just a starting help for new grammars. Anyone who wants more fine-grained control over their syntactical highlighting should deactivate the
textMate
option in theirlangium-config.json
and write/modify their textMate file by hand. It's basically impossible to infer accurate syntactical highlighting just based on a grammar. That's also what we did for the Langium syntax highlighting.Regarding your comments: I'm pretty sure that this style of commenting will lead to a lot of problems down the line. Your
COMMENT
terminal contains a greedy[\s\S]*
regex (compare to the non-greedy[\s\S]*?
regex), which basically par…