-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
schema: Add custom token modifiers #99
Conversation
fa445c3
to
75dcb36
Compare
75dcb36
to
c6585b8
Compare
Name = lang.SemanticTokenModifier("terraform-name") | ||
Type = lang.SemanticTokenModifier("terraform-type") | ||
RequiredProviders = lang.SemanticTokenModifier("terraform-requiredProviders") | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is probably the most important part of the PR.
It's worth noting that these modifiers - similar to token types - share a global namespace (at least in VSCode) - and so should be prefixed. There doesn't seem to be a way of scoping token modifiers or types to just a single language ID in VSCode.
Two minor changes I'm thinking about here is possibly terraform-name
=> terraform-label-name
& terraform-type
=> terraform-label-type
, just to make it more obvious these are used in the context of labels. However it may look kinda awkward/unnecessary when used in the VSCode theme addressing scheme, such as
{
"semanticTokenColors": {
"hcl-blockLabel.terraform-resource.terraform-type": "#ff0011",
"hcl-blockLabel.terraform-resource.terraform-name": "#ff0011"
}
}
vs
{
"semanticTokenColors": {
"hcl-blockLabel.terraform-resource.terraform-label-type": "#ff0011",
"hcl-blockLabel.terraform-resource.terraform-label-name": "#ff0011"
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would stick with terraform-type
and terraform-type
because, as you said, the other choices look kinda unnecessary verbose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Related to hashicorp/vscode-terraform#958
This is admittedly somewhat boring PR, just updating all the different parts of schema to make use of the new changes introduced in hashicorp/hcl-lang#106 and essentially allow Language Server to use the
hcl-lang
decoder along with this updated schema to report these custom modifiers for relevant parts of configuration.