Skip to content
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

Merged
merged 1 commit into from
Mar 18, 2022
Merged

Conversation

radeksimko
Copy link
Member

@radeksimko radeksimko commented Mar 15, 2022

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.

@radeksimko radeksimko added the enhancement New feature or request label Mar 15, 2022
@radeksimko radeksimko self-assigned this Mar 15, 2022
@radeksimko radeksimko force-pushed the f-custom-token-modifiers branch 3 times, most recently from fa445c3 to 75dcb36 Compare March 16, 2022 18:07
Name = lang.SemanticTokenModifier("terraform-name")
Type = lang.SemanticTokenModifier("terraform-type")
RequiredProviders = lang.SemanticTokenModifier("terraform-requiredProviders")
)
Copy link
Member Author

@radeksimko radeksimko Mar 16, 2022

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"
    }
}

Copy link
Member

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.

Copy link
Member

@dbanck dbanck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@radeksimko radeksimko merged commit 7784c24 into main Mar 18, 2022
@radeksimko radeksimko deleted the f-custom-token-modifiers branch March 18, 2022 13:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants