Semantic coloring is a technic which can highlight your commands in different colors according to the semantic meaning of command arguments.
You can toggle the
datapack.features.semanticColoring setting to enable/disable semantic coloring of DHP.
Also, if you’re using VS Code, please make sure that the
editor.semanticHighlighting.enabled setting is set to
if you want to experience this feature, otherwise the editor won’t render these colors.
Semantic Token Types
Semantic Token Modifiers
Recommended Default Styles
| Semantic Token Selector | TextMate Scope | Note |
| - | - | - |
markup.heading.annotation.mcfunction | A doc comment annotation |
constant.language.boolean.mcfunction | A boolean value |
comment | N/A | - |
support.class.entity.mcfunction | An entity or a score holder |
keyword | N/A |
.. in number ranges and time units |
keyword.other.mcfunction | A literal argument |
keyword.control.mcfunction | A literal argument which is also the first argument |
entity.name.function | A namespaced ID |
number | N/A | - |
operator | N/A |
/=, etc. |
property | N/A | entity selector arguments keys, block property keys, NBT compound tag keys, and NBT path keys |
string | N/A | - |
type | N/A | Item slots, scoreboard slots, and objective criteria |
variable | N/A | Objectives, teams, and tags |
constant.numeric.vector.mcfunction | A vector |
N/Ameans that this token is a built-in token in LSP and should have default styles already.
Q: I’m using VS Code. Can I still install Arcensoth’s language-mcfunction, another VS Code extension that provides syntax highlighting for mcfunctions?
Yes, and we encourage you to do so! Arcensoth’s language-mcfunction extension. The language-mcfunction extension uses TextMate grammar that is based on regular expressions and computed on client side, while the language server’s semantic coloring is based on semantic tokens and computed on server side. As a result, the process time of language-mcfunction is much shorter than the language server. By using both extensions, you can get immediate feedback from Arcensoth’s extension while typing commands, which might be replaced with a more accurate color provided by the language server.
Also, there are some drawbacks of the semantic coloring provided by the language server, mostly by design:
- The language server doesn’t provide coloring for text components, while Arcensoth’s language-mcfunction does. This is because the server uses VS Code’s vscode-json-languageservice package to provide completions and validations for text components, which doesn’t support semantic coloring.
- The language server doesn’t provide coloring for punctuations, like the brackets and commas in entity selectors, while Arcensoth’s language-mcfunction does.
Q: I’m using VS Code. Can I customize the colors? They are ugly!
Yes, for sure! In fact the language server doesn’t provide any actual colors; it only provides several semantic tokens that will be interpreted to different colors by your theme in VS Code.
Q: Can I disable your semantic coloring?
Yes, by turning either
datapack.features.semanticColoring off in your settings.
|1.13.0||Implemented semantic coloring.|
|2.0.0||Added semantic coloring.|