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

Support for type declarations (for variable type) #490

Closed
radeksimko opened this issue May 6, 2021 · 2 comments · Fixed by #545
Closed

Support for type declarations (for variable type) #490

radeksimko opened this issue May 6, 2021 · 2 comments · Fixed by #545
Labels
enhancement New feature or request release-blocking planned release will not ship without this textDocument/completion textDocument/hover textDocument/semanticTokens Semantic syntax highlighting
Milestone

Comments

@radeksimko
Copy link
Member

radeksimko commented May 6, 2021

Use-cases

Completion

Given a config

variable "test" {
  type = # HERE
}

when user triggers completion in the highlighted position, they are presented with all available types, e.g. string, number, bool, object() etc.

Hover

There doesn't seem to be any reasonable use case for hover - we would duplicate (and reformat) the type declaration, or just display "type declaration".

Semantic Tokens

Given a config

variable "test" {
  type = string
}
variable "foo" {
  type = list(number)
}
variable "bar" {
  type = object({
    foo = string
  })
}

all of string, list(number), object(...) will be highlighted accordingly by clients which support semantic tokens.

Proposal

Notes

Terraform is currently running an experiment with "optional attributes" for object types. The relevant logic is currently only present in Terraform itself, and not typeexpr package, and so for simplicity it's better to just ignore that experiment, i.e. avoid completing optional().

https://www.terraform.io/docs/language/expressions/type-constraints.html#experimental-optional-object-type-attributes

@radeksimko radeksimko added the enhancement New feature or request label May 6, 2021
@danieldreier danieldreier added this to the v0.20 milestone May 25, 2021
@danieldreier danieldreier added the release-blocking planned release will not ship without this label May 25, 2021
@radeksimko radeksimko changed the title Support for type declarations (for variable types) Support for type declarations (for variable type) May 26, 2021
beandrad added a commit to aztfmod/hcl-lang that referenced this issue Jun 7, 2021
So that completion, hover and semantic-tokens work for variable `type`.

Related to hashicorp/terraform-ls#490
beandrad added a commit to aztfmod/terraform-schema that referenced this issue Jun 7, 2021
To support type declarations for variable `type`.

Related to hashicorp/terraform-ls#490
beandrad added a commit to aztfmod/hcl-lang that referenced this issue Jun 7, 2021
So that completion, hover and semantic-tokens work for variable `type`.

Related to hashicorp/terraform-ls#490
beandrad added a commit to aztfmod/terraform-schema that referenced this issue Jun 7, 2021
So that completion, hover and semantic-tokens work for variable `type`.

Related to hashicorp/terraform-ls#490
beandrad added a commit to aztfmod/terraform-schema that referenced this issue Jun 7, 2021
So that completion, hover and semantic-tokens work for variable `type`.

Related to hashicorp/terraform-ls#490
beandrad added a commit to aztfmod/terraform-schema that referenced this issue Jun 7, 2021
So that completion, hover and semantic-tokens work for variable `type`.

Related to hashicorp/terraform-ls#490
beandrad added a commit to aztfmod/hcl-lang that referenced this issue Jun 7, 2021
So that completion, hover and semantic-tokens work for variable `type`.

Related to hashicorp/terraform-ls#490
beandrad added a commit to aztfmod/terraform-schema that referenced this issue Jun 7, 2021
So that completion, hover and semantic-tokens work for variable `type`.

Related to hashicorp/terraform-ls#490
beandrad added a commit to aztfmod/hcl-lang that referenced this issue Jun 8, 2021
So that completion, hover and semantic-tokens work for variable `type`.

Related to hashicorp/terraform-ls#490
beandrad added a commit to aztfmod/terraform-schema that referenced this issue Jun 8, 2021
So that completion, hover and semantic-tokens work for variable `type`.

Related to hashicorp/terraform-ls#490
beandrad added a commit to aztfmod/hcl-lang that referenced this issue Jun 9, 2021
So that completion, hover and semantic-tokens work for variable `type`.

Related to hashicorp/terraform-ls#490
beandrad added a commit to aztfmod/terraform-schema that referenced this issue Jun 9, 2021
So that completion, hover and semantic-tokens work for variable `type`.

Related to hashicorp/terraform-ls#490
beandrad added a commit to aztfmod/hcl-lang that referenced this issue Jun 9, 2021
So that completion, hover and semantic-tokens work for variable `type`.

Related to hashicorp/terraform-ls#490
radeksimko pushed a commit to hashicorp/hcl-lang that referenced this issue Jun 9, 2021
So that completion, hover and semantic-tokens work for variable `type`.

Related to hashicorp/terraform-ls#490
beandrad added a commit to aztfmod/terraform-schema that referenced this issue Jun 9, 2021
So that completion, hover and semantic-tokens work for variable `type`.

Related to hashicorp/terraform-ls#490
radeksimko pushed a commit to hashicorp/terraform-schema that referenced this issue Jun 9, 2021
So that completion, hover and semantic-tokens work for variable `type`.

Related to hashicorp/terraform-ls#490
@radeksimko
Copy link
Member Author

Completion, hover and semantic highlighting for variable type will be provided in the upcoming release.

Here is a screenshot:

Screenshot 2021-06-10 at 10 15 00

Please keep in mind that we do not yet support completion for "nested expressions" which means that you can complete an empty type = but not types within map, set, list etc.

Screenshot 2021-06-10 at 10 21 13

This functionality is tracked under #496 - feel free to upvote and/or subscribe if that is important to you.

@radeksimko radeksimko modified the milestones: v0.20, v0.18 Jul 8, 2021
@github-actions
Copy link

github-actions bot commented Aug 8, 2021

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 Aug 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request release-blocking planned release will not ship without this textDocument/completion textDocument/hover textDocument/semanticTokens Semantic syntax highlighting
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants