hashicorp / vscode-terraform

HashiCorp Terraform VSCode extension
https://marketplace.visualstudio.com/items?itemName=HashiCorp.terraform
Mozilla Public License 2.0
917 stars 179 forks source link

Autocomplete is not working & does not provide suggestion #999

Closed ktasper closed 2 years ago

ktasper commented 2 years ago

Versions

This bug is reproducible in:

Extension

HashiCorp Terraform v2.20.0

Language Server

{"name":"terraform-ls","version":"0.25.2"}}

VS Code

Version: 1.65.2 (Universal)
Commit: c722ca6c7eed3d7987c0d5c3df5c45f6b15e77d1
Date: 2022-03-10T14:33:49.188Z (6 days ago)
Electron: 13.5.2
Chromium: 91.0.4472.164
Node.js: 14.16.0
V8: 9.1.269.39-electron.0
OS: Darwin arm64 21.2.0

Operating System

MacBook Air (M1, 2020)
Version 12.1 (21C52) Monterey
Chip Apple M1
Memory 16GB

Terraform Version

Terraform v1.1.7
on darwin_amd64
+ provider registry.terraform.io/gavinbunney/kubectl v1.13.1
+ provider registry.terraform.io/hashicorp/google v4.12.0
+ provider registry.terraform.io/hashicorp/google-beta v4.12.0
+ provider registry.terraform.io/hashicorp/kubernetes v2.8.0
+ provider registry.terraform.io/hashicorp/null v3.1.0
+ provider registry.terraform.io/hashicorp/random v3.1.0

Steps To Reproduce

  1. Open up a terraform dir and attempt to use the autocompletion / intellisense.
.
├── backends.tf
├── database.tf
├── dns.tf
├── files
│   └── static_site
│       ├── index.html
│       └── robots.txt
├── ingress.tf
├── outputs.tf
├── providers.tf
├── secrets.tf
├── tls.tf
└── variables.tf

Expected Behavior

Intellisense / Autocomplete should work Screenshot 2022-03-17 at 09 52 02 As in attached screenshot I should get a autocomplete option for resource

Actual Behavior

Nothing happens

Other Notes

ktasper commented 2 years ago

Update:

Just fixed it, its amazing what filing a bug report can do for my own troubleshooting!

The language association was set to hcl which I thought was correct, but it needed to be set to terraform and now it works.

radeksimko commented 2 years ago

The language association was set to hcl which I thought was correct, but it needed to be set to terraform and now it works.

I will just add that the best practice we recommend to follow is not to change the default file associations. The extension should be able to figure this out automatically as per https://github.com/hashicorp/vscode-terraform/blob/bd7035aea6509e6c744a441eca6fe9c02290dc06/package.json#L54-L72

Also we have plans to soon address the other (not Terraform) HCL files via https://github.com/hashicorp/vscode-terraform/issues/639

github-actions[bot] commented 2 years ago

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.