Comments (19)
It looks like the terraform.formatOnSave
setting was removed in favor of using the built-in editor.formatOnSave
setting. If you want to enable format-on-save only for Terraform files, you can add the following to your user settings or workspace settings:
{
"[terraform]": {
"editor.formatOnSave": true
}
}
from vscode-terraform.
Still doesn't work for me, i have re-installed the plugins several time and also set both "editor.formatOnSave": true
and "terraform.format.enable": true
from vscode-terraform.
@mauve I wasn't aware of the editor.formatOnSave
setting.. that fixed it. thanks for clearing it up!
from vscode-terraform.
broken for me as well...
EDIT: I reinstalled the extension and enabled both: "editor.formatOnSave": true & "terraform.format.enable": true.
That seems to work.
from vscode-terraform.
Also getting this behavior under 0.0.20. VScode details:
from vscode-terraform.
As a workaround, I figured out how to install the previous version:
This stackoverflow answer guides you through the process. The link to download the previous version is here.
I needed to rename the file with a proper vsix file extension and restart vscode afterward. Use the previous config values (now deprecated) and it should work again.
from vscode-terraform.
Actually the changelog mentions this: https://github.com/mauve/vscode-terraform/blob/master/CHANGELOG.md#0020.
from vscode-terraform.
I should have been more clear, @jacobwgillespie . That config was tried, the old style config was removed (no problems in settings.json), and under the new extension version the Terraform output console shows terraform fmt
successfully running against files that continue to not get formatted. I think there's still a bug here unless there's something I've overlooked.
terraform.format: running 'terraform fmt' on '/Users/brandonoconnor/Development/git/foo/variables.tf'
terraform.format: Successful.
from vscode-terraform.
Ah, I see, gotcha. Well in that case, I can confirm that format-on-save is working for me with the above settings, vscode-terraform version 0.0.20, and VS Code 1.19.0. Do you have any other settings or extensions that might influence file formatting?
from vscode-terraform.
I just tried to reproduce this but cannot reproduce for editor.formatOnSave
. Format on save works for me with the following setting:
"editor.formatOnSave": true
or
{
"[terraform]": {
"editor.formatOnSave": true
}
}
However format on save does not work with editor.autoSave
which I think is by design in VSCode, at least this is what the settings documentation says:
// Format a file on save. A formatter must be available, the file must not be auto-saved, and editor must not be shutting down.
"editor.formatOnSave": false,
The formatter does not even seem to be invoked when editor.autoSave
is true
, however manually invoking save by Cmd+S
or Ctrl+S
.
from vscode-terraform.
@cludden: just a quick fyi: tflint
is for linting, it has nothing with formatting to do. Formatting is done by terraform fmt
, you should see the following output in the Output tab:
terraform.format: running 'terraform fmt' on '/Users/olenfalk/projects/vscode-terraform/templates/template.tf'
terraform.format: Successful.
from vscode-terraform.
@brandoconnor @cludden just to be clear do you have problems with the formatOnSave
in general or is it the removal/breakage of the formatOnAutoSave
feature which you are referring to?
from vscode-terraform.
Format on save is disabled when the save reason is auto:
from vscode-terraform.
@cludden - Nope still not fixed here. Please reopen.
@mauve - I've verified that "editor.formatOnSave": true
, editor.autoSave
is non-existent (not even a valid configuration), and formatting is working on other file types. As mentioned in my previous comment, terraform.format
shows the expected output on the correct file but nothing happens to the file. If I go to the terminal and terraform fmt
manually, the file is formatted, but the extension is still not doing what it claims to be doing in the output. Any other settings to try or debugging that can be turned up?
from vscode-terraform.
@brandoconnor ok I will take another look tonight, sorry for breaking your setup, if you can think of any other info which might narrow this down for me please keep commenting here.
from vscode-terraform.
Just tried once more with both settings as suggested on #46 and that wasn't successful.
from vscode-terraform.
Seems like uninstalling and re-installing the extension helps
from vscode-terraform.
Wish I could have that same story @mspaulding06 🤷♀️ . I've probably uninstalled and reinstalled the new version 10x in the course of troubleshooting.
from vscode-terraform.
Hi guys, thanks for being patient:
Please test the new version and tell me if it still doesn't work for you:
0.0.21
What's New
- Auto completion support @ranga543
- Format on save is back (closes #45, #47)
- Tools can now be installed in directories which have spaces @xeres
Format on save
The last version introduced usage of the correct extension APIs for registering formatting
providers. VSCode then automatically invokes the formatting provider on save if editor.formatOnSave
has been specified. VSCode however does never invoke the formatting
provider if the save operation came from an auto-save event.
0.0.21 reintroduces the manual code which handled format on autosave instead of relying on
VSCode to perform those operations. The following configuration options have changes as result
of that:
terraform.format.enable
: needs to betrue
terraform.format.formatOnSave
: needs to betrue
terraform.format.ignoreExtensionsOnSave
: can be used to exclude.tfvars
for example from autosave formatting
The global setting: editor.formatOnSave
should be false
for Terraform files and the
extension contributes that default configuration. Please verify that you do not have
conflicting configuration, by removing the following setting if you have it:
"[terraform]": {
"editor.formatOnSave": true
}
The configuration editor.formatOnSave
will have the correct setting contributed by Terraform.
from vscode-terraform.
Related Issues (20)
- Extension shows a deprecation for an attribute but not the reason HOT 2
- Terraform intellisense is not showing when using module with github as the source HOT 2
- Completions for variables include the var. (unless you don't type the dot) HOT 3
- Syntax Highlighting Breaks If a Function is Split Over Multiple Lines When in String Interpolation HOT 1
- "tags" not expected in `aws_budgets_budget` HOT 3
- Error in transit_encryption_mode attribute on AWS aws_elasticache_replication_group Resource HOT 3
- "Unexpected attribute: An attribute named "private_endpoint_network_policies" is not expected here" HOT 3
- Secret_environment_variables in the service_config block of google_cloudfunctions2_function does not accept array HOT 2
- Syntax validation throwing incorrect errors for Terraform Test files (`*.tftest.hcl`) HOT 8
- Heredoc causes text cursor to freeze HOT 3
- Terraform Linter reports error with WAFv2 rule_action_override but matches documentation HOT 6
- Intellisense completion for variable identifier replaces var.name with var.var.name
- Syntax highlighting broken with `SELECT` statements HOT 3
- Autocomplete stops working from one file to another in the same module HOT 14
- Unexpected attribute error for terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks HOT 4
- Linter Syntax validation not refreshing after editing file HOT 2
- "Format On Save" fails even when Terraform is on PATH HOT 2
- azurerm_storage_account https_traffic_only_enabled not recognized HOT 4
- format Document is not working in VS code
- VS Code uses 250% CPU when it discovered an "error" (works in version of provider, does not work in the later version of provider).
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vscode-terraform.