It can have values true, false, and configuredByTheme. Whether semantic tokens are computed and highlighted is decided by the setting. Instead, subtypes need to redefine the mapping, preferably to more specific scopes. Note that custom mapping rules are not automatically inherited from the super type. This is described in the Custom Mappings section. The semanticTokenColors value "#ff0011" shown above applies to both type and all it's subtypes, including templateType.Īlong with custom token types, extensions can define how these are mapped to TextMate scopes. SemanticTokensLegend ( tokenTypes, tokenModifiers ) const provider : vscode. const tokenTypes = const tokenModifiers = const legend = new vscode. The editor will make requests to the providers when semantic tokens are needed. To implement semantic highlighting, language extensions can register a semantic token provider by document language and/or file name.
Here's an example of what semantic highlighting can add: The editor applies the highlighting from semantic tokens on top of the highlighting from grammars.
Themes can opt in to use semantic tokens to improve and refine the syntax highlighting from grammars.
TEXTMATE LATEX HOW TO
Semantic tokenization allows language servers to provide additional token information based on the language server's knowledge on how to resolve symbols in the context of a project. TextMate grammars work on a single file as input and break it up based on lexical rules expressed in regular expressions. Visual Studio Code uses TextMate grammars as the main tokenization engine. Semantic highlighting is an addition to syntax highlighting as described in the Syntax Highlight guide.