longkai / kubernetes-yaml-formatter

Kubernetes Style YAML Formatter for Visual Studio Code
MIT License
41 stars 3 forks source link

Question: how to apply it to helm-template files? #8

Open RafalSkolasinski opened 1 year ago

RafalSkolasinski commented 1 year ago

This is great, finally sane indent for list in Kubernetes / Ansible yaml files. Just a question - how can I make it also work if file is recognized as helm-template?

I tried to set

    "[helm-template]": {
        "editor.defaultFormatter": "kennylong.kubernetes-yaml-formatter"
    },

but VS Code still complains that "There is no formatter for 'helm' files installed.".

pie-r commented 1 year ago

I did it in this way:

  "[yaml]": {
    "editor.defaultFormatter": "kennylong.kubernetes-yaml-formatter",
    "editor.formatOnSave": true
  },
  "files.associations": {
    "*.yml": "yaml",
    "*.yaml": "yaml"
  },
  "editor.defaultFormatter": "esbenp.prettier-vscode",
longkai commented 1 month ago

Hi!

Sorry for the delay.

I use helm very often. But since helm is not really yaml but a template-engine we cannot format the mixed two directly.

However, for the template part you can use builtin function like indentn.

for the yaml part, the new v2 version has implemented a range format, so just select range code and the extension will format those region.

longkai commented 1 week ago

You can config with(which is the default value):

"[helm]": {
  "editor.defaultFormatter": "kennylong.kubernetes-yaml-formatter",
  "editor.formatOnSave": false
},
"[ansible]": {
  "editor.defaultFormatter": "kennylong.kubernetes-yaml-formatter",
  "editor.formatOnSave": false
}