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

internal/lsp: recognize type declarations as semantic tokens #827

Merged
merged 3 commits into from
Mar 7, 2022

Conversation

radeksimko
Copy link
Member

Closes #816

Before

Screenshot 2022-03-04 at 15 35 58 Screenshot 2022-03-04 at 15 36 10

After

Screenshot 2022-03-04 at 15 36 31 Screenshot 2022-03-04 at 15 36 44


Related Thoughts

It is possible that we may want to replace the two tokens with something even more accurate, like TokenTypeString, TokenTypeNumber, TokenTypeSet, TokenTypeList etc. but it is currently unclear whether anyone would actually benefit from that. We can always revisit supported tokens later.

We can also see that the VSCode grammar highlights types as variables. I would say that keyword scope is more appropriate, as that leaves variable scope for HCL traversals and allows us to visually distinguish the two. i.e. We can adjust the highlighting of primitive types like string, number, null or bool in the grammar as well.

@radeksimko radeksimko added enhancement New feature or request textDocument/semanticTokens Semantic syntax highlighting workspace/semanticTokens labels Mar 4, 2022
@radeksimko radeksimko self-assigned this Mar 4, 2022
@radeksimko radeksimko added this to the v0.26.0 milestone Mar 4, 2022
@radeksimko radeksimko requested a review from a team March 4, 2022 15:41
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.

LGTM 👍

@radeksimko radeksimko merged commit 8938b93 into main Mar 7, 2022
@radeksimko radeksimko deleted the f-type-decl-highlighting branch March 7, 2022 09:50
@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.

Semantic token highlighting for variable type declarations
2 participants