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

Completion/hover/highlighting for variable default #537

Closed
radeksimko opened this issue May 26, 2021 · 1 comment · Fixed by #543
Closed

Completion/hover/highlighting for variable default #537

radeksimko opened this issue May 26, 2021 · 1 comment · Fixed by #543

Comments

@radeksimko
Copy link
Member

radeksimko commented May 26, 2021

Will likely depend on #50 or at least on some parts of it.

Use-cases

Completion

Given a config

variable "test" {
  type = object({
    port = number
    protocol = string
  })
  default = {
    # HERE
  }
}

when user triggers completion in the highlighted position, they are presented with two candidates:

  • port number
  • protocol string

Hover

When user hovers over the expression after default = , they will be provided with a relevant popup describing type of the expression. For example

variable "test" {
  type = map(string)
  default = {
    alpha = "A"
    beta = "B"
  }
}

when hovering over { alpha ... } they would be presented with map(string).

In most cases this would basically be just whatever is in type, but if type = any, type = list(any) and similar, the hover popup should reflect the real type inferred from the value (as long as it is compatible).

Semantic Tokens

Given a config

variable "test" {
  type = string
  default = "blah"
}
variable "foo" {
  type = list(number)
  default = [ 1, 3, 5 ]
}
variable "bar" {
  type = object({
    foo = string
  })
  default = {
    foo = "test"
  }
}
  • "blah" will be reported as string
  • 1, 3 and 5 will be reported as number
  • foo will be reported as attribute name
  • "test" will be reported as string

Proposal

beandrad added a commit to aztfmod/terraform-schema that referenced this issue Jun 4, 2021
To support completion/hover/highlighting for variable `default`.

As part of this change, the `default` attribute was removed from the
variable schema block so that it can be set by the decoder.

Related to hashicorp/terraform-ls#537
beandrad added a commit to aztfmod/terraform-schema that referenced this issue Jun 4, 2021
To support completion/hover/highlighting for variable `default`.

As part of this change, the `default` attribute was removed from the
variable schema block so that it can be set by the decoder.

Related to hashicorp/terraform-ls#537
radeksimko pushed a commit to hashicorp/terraform-schema that referenced this issue Jun 4, 2021
To support completion/hover/highlighting for variable `default`.

As part of this change, the `default` attribute was removed from the
variable schema block so that it can be set by the decoder.

Related to hashicorp/terraform-ls#537
radeksimko pushed a commit that referenced this issue Jun 10, 2021
So that completion/hover/highlighting is available for variable
`default`.

Fixes #537
@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 Jul 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant