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

Update semantic token block label type #802

Merged
merged 1 commit into from
Feb 23, 2022
Merged

Conversation

dbanck
Copy link
Member

@dbanck dbanck commented Feb 23, 2022

This PR updates the type for block labels from string to enum member.

It's the first step in providing more contextual information on block labels. With a schema update, it will be possible to differentiate between multiple block labels. This will allow us to report two different tokens for block labels where the first one stays enum member and the second one becomes a string.

We've tried different token types, like class, macro, method, and enumMember and settled on the latter. enumMember makes the most sense from a semantic perspective and has good highlighting in the default themes.

Having semantic tokens for block labels enables better highlighting for nested blocks.

Before (no LS)
CleanShot 2022-02-23 at 15 23 06

After (with LS)
CleanShot 2022-02-23 at 15 26 55

For a smoother user experience, we propose to update the static grammar for block labels from entity.name.tag.terraform to variable.other.enummember. This change would update the raw grammar version (no LS) to this:
CleanShot 2022-02-23 at 15 28 43

Closes #777

@dbanck dbanck added enhancement New feature or request textDocument/semanticTokens Semantic syntax highlighting workspace/semanticTokens labels Feb 23, 2022
@dbanck dbanck force-pushed the f-resource-block-label-token branch from f49c331 to 0b8cd74 Compare February 23, 2022 14:47
Copy link
Member

@radeksimko radeksimko left a comment

Choose a reason for hiding this comment

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

LGTM

@jpogran
Copy link
Contributor

jpogran commented Feb 23, 2022

Depending on your theme, the 'no LS' does highlight differently than strings.

Dark+ (default):
image

Light+:
image

I do agree on aligning the scopes between the textmate grammar and the semantic token, just pointing out it does do something :)

@github-actions
Copy link

This functionality has been released in v0.26.0 of the language server.
If you use the official Terraform VS Code extension, it will prompt you to upgrade to this version automatically upon next launch or within the next 24 hours.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request textDocument/semanticTokens Semantic syntax highlighting workspace/semanticTokens
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Token identification for resource block label
3 participants