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

Semantic token highlighting for variable type declarations #816

Closed
radeksimko opened this issue Mar 2, 2022 · 2 comments · Fixed by #827
Closed

Semantic token highlighting for variable type declarations #816

radeksimko opened this issue Mar 2, 2022 · 2 comments · Fixed by #827
Assignees
Labels
enhancement New feature or request textDocument/semanticTokens Semantic syntax highlighting workspace/semanticTokens
Milestone

Comments

@radeksimko
Copy link
Member

Use-cases

Improve accuracy of highlighting via semantic tokens for type declarations via semantic tokens.

variable "test" {
  type = object({
    test_object = map(
      object({
        test_map = string
      })
    )
  })
}

Proposal

Type declarations already seem to be reported by hcl-lang as TokenTypeCapsule and TokenTypePrimitive.

The goal is to choose appropriate LSP token types to translate these into.

switch token.Type {
case lang.TokenBlockType:
tokenType = TokenTypeType
case lang.TokenBlockLabel:
tokenType = TokenTypeEnumMember
case lang.TokenAttrName:
tokenType = TokenTypeProperty
case lang.TokenBool:
tokenType = TokenTypeKeyword
case lang.TokenNumber:
tokenType = TokenTypeNumber
case lang.TokenString:
tokenType = TokenTypeString
case lang.TokenObjectKey:
tokenType = TokenTypeParameter
case lang.TokenMapKey:
tokenType = TokenTypeParameter
case lang.TokenKeyword:
tokenType = TokenTypeVariable
case lang.TokenTraversalStep:
tokenType = TokenTypeVariable
default:
return []uint32{}
}

@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 issue 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 similar to this, 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 a pull request may close this issue.

1 participant