Closed johnnyplaydrums closed 5 years ago
This actually has nothing to do with 0.12 syntax, I'm just wondering how to get the formatter to working when the linter is complaining. If that's not possible, how can I disable the linter? Thank you
Formatting doesn't work if you have syntax errors, are you sure that you have no errors? Please post a screenshot?
Yes, the linter says I have errors because 0.12 syntax isn't supported right? So I was wondering if there was a way to get the formatter to continuing working while the linter is complaining. If not, can I disable the linter?
Linting is only done on-demand if you manually invoke the command terraform.lint
(Terraform: Lint). Can you please post a screenshot of your problems view?
When I say linting, I'm referring to the red underline that happens when there is improper syntax. This appears after every keystroke and after every save. If the syntax is incorrect and the red line appears, formatting does not happen on save. In the below picture, I would expect formatting to correct the spacing of the =
. Once I fix the below bracket and save, formatting aligns the =
. Is there a way to get formatting to still work even with improper syntax? If not, is there a way to disable the feature that prevents formatting on save from working when there is a syntax error?
Formatting is performed by calling 'terraform fmt', terraform only formats files it can parse without errors.
Sent from my iPhone
On 25. Apr 2019, at 03:33, John Spencer notifications@github.com wrote:
When I say linting, I'm referring to the red underline that happens when there is improper syntax. This appears after every keystroke and after every save. If the syntax is incorrect and the red line appears, formatting does not happen on save. In the below picture, I would expect formatting to correct the spacing of the =. Once I fix the below bracket and save, formatting aligns the =. Is there a way to get formatting to still work even with improper syntax? If not, is there a way to disable the feature that prevents formatting on save from working when there is a syntax error?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.
Ah duh, makes sense, sorry I didn't check that before asking. I guess my question now is, can I get this extension to work with terraform 0.12 syntax? I have 0.12 installed locally, and it's able to parse and format this correct when I call terraform fmt
from the command line. But in vs code, there is a parsing error due to 0.12 syntax, and there format doesn't work. Anyway around that? In the example below, vs code won't align the =
due to parsing 0.12 syntax, but when I run terraform fmt
from the command line it works.
Can you check in the output tab (under Terraform) which terraform
binary is picked up by the vscode-plugin?
Ok thank you for the help! I followed the errors I was seeing in the console and fixed it - it didn't find the terraform executable because I installed through asdf
. Putting a .tool-versions
in ~/ fixed it. Now formatting is working but the 0.12 syntax is still underlined in red. Anything else I can do to fix that? The vs code console is not showing any errors.
that is because the internal syntax parser does not support HCL2, sadly there are no plans to support it any time soon.
You don't have to support Terraform 0.12 - but then you should not call the plugin "Terraform". Or at least leave the issue open so other people can see that it's an ongoing thing.
There is an open issue for it, and it seems like some folks have started to look into it.
@ggPeti the plugin existed before Terraform 0.12 was released, feel free to contribute to the plugin if it is not to your liking
This has nothing to do with my liking. A plugin that doesn't support Terraform's current official language is not a Terraform plugin.
@ggPeti maybe you can ask for your money back?
Hello! First off, thanks for the awesome extension 😄. I just started using terraform 0.12, and I noticed that the linter is complaining about some of the new syntax. I was just going to ignore it, but then I realized that formatting stopped working as well due to the improper syntax. In tf files using terraform 0.11 syntax, linting and formatting works fine. But on 0.12 files, the formatter doesn't format until I revert to 0.11 syntax (making the linter happy). Is it the linter that's blocking formatting? Can I disable the linter? Or what's the best way around this? Thank you!