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 step-based reference completion #492

Closed
radeksimko opened this issue May 6, 2021 · 1 comment · Fixed by #566
Closed

Support step-based reference completion #492

radeksimko opened this issue May 6, 2021 · 1 comment · Fixed by #566
Assignees
Labels
Milestone

Comments

@radeksimko
Copy link
Member

Current Version

0.17 (future version which will have basic reference support)

Context

References in HCL/Terraform have steps separated by . or brackets [ ]. As part of initial work on reference completion, references (including those special characters) are treated as opaque strings. For example when user requests completion in the following config

resource "aws_instance" "example" {
# ...
}
output "foo" {
  value = # HERE
}

they are presented with all known attributes of aws_instance.example (and any other resources and data sources declared in the config), e.g.

aws_instance.example.ami
aws_instance.example.associate_public_ip_address
aws_instance.example.availability_zone
aws_instance.example.cpu_core_count
# ... etc

This could be overwhelming in larger configurations.

Use-cases

While I believe this can be valuable, I'm not sure yet how to best surface it to the users yet.

Step-based only completion

Provide user with just the first known reference step i.e. up to the first . or [ and treat . and [ as completion trigger characters in that context.

Using the example config above, user would only be presented with aws_instance.example (ignoring the builtin references such as terraform.workspace). Then once they confirm the option, they'll be presented with next steps, e.g. credit_specification, once they confirm and are presented with cpu_credits.

Step-based completion prioritized

Some users might like both fully expanded references and the above step-based completion. We could provide both and prioritize "parent" references in the list.

Using the example config above, user would be presented with the following candidates in that exact order

aws_instance.example
aws_instance.example.ami
aws_instance.example.associate_public_ip_address
aws_instance.example.availability_zone
aws_instance.example.cpu_core_count

i.e. aws_instance.example is first on the list.

Proposal

TODO

@github-actions
Copy link

github-actions bot commented Aug 6, 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 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant