You need an editor (like IntelliJ) that can do highlighting in two phases:
1. syntax highlighting -- This either works at the lexical/token level (like IntelliJ) or via regular expressions and other patterns (like VSCode and Vim).
2. semantic highlighting -- This typically works on a parsed syntax tree to be able to highlight if a variable is a class member variable, etc. For IntelliJ this is done via annotations that you can set on a token or tokens.
There's technically a third phase for embedded languages. In IntelliJ the host language needs to implement the part of the AST tree (e.g. a string or XML text node) as being able to host an embedded language. The host language IIRC is then responsible for detecting the embedded language, e.g. by the XML element name and attribute or via a language comment for a string. The IDE will then embed that language in the text/string/etc. node. -- I'm not sure how this works in other IDEs/editors.
1. syntax highlighting -- This either works at the lexical/token level (like IntelliJ) or via regular expressions and other patterns (like VSCode and Vim).
2. semantic highlighting -- This typically works on a parsed syntax tree to be able to highlight if a variable is a class member variable, etc. For IntelliJ this is done via annotations that you can set on a token or tokens.
There's technically a third phase for embedded languages. In IntelliJ the host language needs to implement the part of the AST tree (e.g. a string or XML text node) as being able to host an embedded language. The host language IIRC is then responsible for detecting the embedded language, e.g. by the XML element name and attribute or via a language comment for a string. The IDE will then embed that language in the text/string/etc. node. -- I'm not sure how this works in other IDEs/editors.