-
Notifications
You must be signed in to change notification settings - Fork 34
Semantic Coloring
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 true
if you want to experience this feature, otherwise the editor won't render these colors.
annotation
boolean
comment
entity
keyword
literal
namespacedID
number
operator
property
string
type
variable
vector
declaration
deprecated
documentation
firstArgument
Semantic Token Selector | TextMate Scope | Note |
---|---|---|
annotation |
markup.heading.annotation.mcfunction |
A doc comment annotation |
boolean |
constant.language.boolean.mcfunction |
A boolean value |
comment |
N/A | - |
entity |
support.class.entity.mcfunction |
An entity or a score holder |
keyword |
N/A |
.. in number ranges and time units |
literal |
keyword.other.mcfunction |
A literal argument |
literal.firstArgument |
keyword.control.mcfunction |
A literal argument which is also the first argument |
namespacedID |
entity.name.function |
A namespaced ID |
number |
N/A | - |
operator |
N/A |
matches , = , /= , 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 |
vector |
constant.numeric.vector.mcfunction |
A vector |
-
N/A
means 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.
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.
You can see VS Code's documentation about how to change those colors. You can also check all the semantic token types and semantic token modifiers used by the language server on this page.
Yes, by turning either editor.semanticHighlighting.enabled
or datapack.features.semanticColoring
off in your settings.
Version | Description |
---|---|
1.13.0 | Implemented semantic coloring. |
2.0.0 | Added semantic coloring. |