Skip to content

[Feature Request] Code completion for resource types available #339

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

Closed
mattwelke opened this issue Nov 3, 2020 · 6 comments
Closed

[Feature Request] Code completion for resource types available #339

mattwelke opened this issue Nov 3, 2020 · 6 comments
Labels

Comments

@mattwelke
Copy link

I like how I can get code completion for attributes for a resource (by typing the first letter or using ctrl-space), but it would be nice too if I had code completion for when I begin typing resource "<prefix>... to help me type a resource that exists in one of my providers. Preferably, I could then hit tab to choose a name for the resource, then hit tab again to have it fill in every required attribute with placeholder values.

For example, I have the AWS provider (version 3.6) installed. If I type like this, and then hit ctrl-space:

image

I get help that is okay, because it can reference strings from my project, but nothing smart from the providers. I'd like if it suggested things like aws_ami or aws_instance.

@aeschright aeschright transferred this issue from hashicorp/vscode-terraform Dec 16, 2020
@radeksimko
Copy link
Member

I will just clarify here, that in VS Code specifically it is possible to have labels, such as aws_instance in resource block, completed automatically, if you choose to also complete the block itself.

2021-02-24 15 36 46

This is done by automatically triggering the completion from the server side. However there is no general support for such mechanism (yet) in LSP and most clients will probably prevent on-type completion within double quotes, because they (reasonably) assume it's just arbitrary literal string.

What does not work at this point - and that is the reason I'd like to still keep this issue open - is when you type the above all by hand:

2021-02-24 15 37 15

@mattwelke
Copy link
Author

Ohh interesting. I can see now that people all have slightly different ways of coding and where they expect to leverage code completion features. For me, I usually type something out in full if I remember it (I can easily remember resource ") and then try to activate code completion when I get to a point where I don't remember stuff (I can't easily remember every possibly Terraform resource given the providers I have installed, especially as I'm learning Terraform). My technique prevents the code completion from being triggered properly.

@radeksimko
Copy link
Member

Just to be clear I wasn't suggesting this is common or correct technique, just a technique that works within the limitations of the LSP.

This is one of the relevant upstream issues discussing the problem: microsoft/language-server-protocol#565 and this is where the current workaround was implemented: #300

@mattwelke
Copy link
Author

Understood. I was just doing a brain dump in case it helps the DX folks who end up addressing this.

@radeksimko
Copy link
Member

In the interest of tracking a feature in one place I'm going to close this in favour of the following issues:

Thank you for understanding.

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

No branches or pull requests

2 participants