panoply / vscode-liquid

💧Liquid language support for VS Code
https://marketplace.visualstudio.com/items?itemName=sissel.shopify-liquid
Other
173 stars 22 forks source link

How do I properly configure workspace for *.html files? #131

Closed anantakrishna closed 1 year ago

anantakrishna commented 1 year ago

I'd prefer my liquid templates to have *.html extension. How do I properly configure VS Code in this case? Note: I'm using prettier and @shopify/prettier-plugin-liquid for formatting instead of built-in formatting of this extension.

This is my attempt.

{
  "files.associations": {
    "*.html": "liquid"
  },
  "editor.defaultFormatter": "esbenp.prettier-vscode",
  "[liquid]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "editor.formatOnSave": true,
  "liquid.format.enable": false,
  "liquid.engine": "standard",
}

Main thing is files.association, I guess. Is my approach correct?

Extension v3.1.1

panoply commented 1 year ago

Hey @anantakrishna

This is the correct configuration. Are you having trouble configuring Prettier to run on the file?

panoply commented 1 year ago

Just out of curiosity, is there any specific reason for using a .html over a .liquid- is there a feature missing per-say?

anantakrishna commented 1 year ago

Are you having trouble configuring Prettier to run on the file?

No, it runs fine. I just was puzzled because in October the Liquid extension would highlight the syntax etc in the HTML files without this files.association setting (as far as I remember), but now when I opened the project again, the extension features were not active in the HTML files. That is why I had to configure files association. Maybe it's due to extension upgrade to v3?

Just out of curiosity, is there any specific reason for using a .html over a .liquid- is there a feature missing per-say?

We're using the Liquid template language in the 11ty project. There, HTML files can be optionally pre-processed with an additional template engine, which is Liquid by default. My templates are mostly plain HTML with sprinkles of Liquid, that is why we considered right to keep the html extension for the files. This is the only reason.

panoply commented 1 year ago

So in previous versions the extension would use injection grammars are extend HTML. This was a little problematic in a lot of cases. As of v3^ Liquid is considered as an official language and HTML features like completions, highlighting and all the rest are still respected in a .liquid file.

We're using the Liquid template language in the 11ty project

I am looking to improve features for 11ty and static site generated projects that employ Liquid as the template language. I'd love to learn more about any wishlist capabilities/features you wish were available. In future versions one of the main capabilities I aim to bring is auto-completion support for data contained in frontmatter. I also believe bringing support for collection based data would be a great benefit.

Any thoughts or feedback would be greatly appreciated, thanks.

anantakrishna commented 1 year ago

Thanks for confirming my guess. After reading v3 release notes I suspected that something changed in handling *.html files :)

As of now in our case I haven't experienced any lack of features or misbehaviour. Should I face any issue, I'll let you know, keeping in mind your kind invitation!