Vad1mo
Vad1mo

Reputation: 5543

Visual Studio Code Handlebars Formatting in YAML breaks syntax

I have a YAML file for helm that got go template style handlebars {{ .Values.domain }} however the formatter turns them into { { .Values.domain } } how can I disable specific behavior.

FYI: The setting "Yaml › Format: Bracket Spacing Print spaces between brackets in objects" is the result {{.Values.domain}} is not valid go template syntax.

This behavior is happening with both formatters I have in VSCode prettier-vscode and redhat-developer/vscode-yaml. I have found out that vscode-yaml is using prettier underneeth.

Upvotes: 6

Views: 5785

Answers (3)

Yeahia Md Abid
Yeahia Md Abid

Reputation: 295

I solved the problem by adding the following code into settings.json

"[helm]": {
    "editor.formatOnSave": false
  }

For open settings.json use the shortcut command + shift + P for mac, for windows use Ctrl+Shift+P.

Upvotes: 1

Luke W
Luke W

Reputation: 8934

I created ~/.prettierignore file, added *.yaml, *.yml to it, then updated vscode User setting "prettier.ignorePath": "~/.prettierignore".

Upvotes: 0

ultraGentle
ultraGentle

Reputation: 6329

  1. Check VSC settings for "space non-empty braces" (I don't remember the exact name of the setting, hence the search).

  2. Make sure it is unchecked.

  3. Set the default formatter for your file type to VSCode, not any formatting extension.

Upvotes: 1

Related Questions