uicrooks / shopify-theme-lab

Shopify theme development environment using Liquid, Vue and Tailwind CSS. Built on top of Shopify CLI 🧪
https://uicrooks.github.io/shopify-theme-lab-docs/
MIT License
737 stars 130 forks source link

VSCode collapses all spaces in a liquid file schema on save #81

Closed schellenbergk closed 3 years ago

schellenbergk commented 3 years ago

Version and operating system

Description

VSCode collapses all spaces in a liquid file schema on save.

Additional Details
https://gifyu.com/image/D6wN

What is Expected?

Properly formatted a Schema

What is actually happening?

All spaces/new line characters removed

arasherr commented 3 years ago

You're probably using prettier as your code formatter and that is causing the issue. a quick workaround is to add prettier-ignore comment before your schema.

{%- comment -%}<!-- prettier-ignore -->{%- endcomment -%}
{% schema %}
{
  ...
}
{% endschema %}

or the better alternative is to install the Liquid extension and set that as your code formatter.

sergejcodes commented 3 years ago

I'm also using VS Code and don't have any problems. Most likely some formatter, like already mentioned, is causing the issue.

schellenbergk commented 3 years ago

Hmmm, none of that helped. But I noticed by default when opening .liquid files the language mode detected is set to HTML not liquid, when I switched to liquid language (manually) then saving did not trigger auto format. Format only worked properly when I run Liquid: Format Document command.

Is there a way to fix language detection in VSCode for liquid files and make the format on save work with it too?

schellenbergk commented 3 years ago

I was able to fix the first issue with:

{
    "files.associations": {
        "*.liquid": "liquid"
    }
}

but the format on save is still an issue.

schellenbergk commented 3 years ago

Just found a fix here: https://github.com/panoply/vscode-liquid/issues/32#issuecomment-748382665 that worked for me