panoply / vscode-liquid

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

Schema snippets should target the Json inside the schema liquid tag instead of the liquid scope #121

Closed muchisx closed 1 year ago

muchisx commented 1 year ago

Hi!

Currently Schema snippets are not working because their scope is liquid: image

But the Schema liquid tag contains Json content, not liquid image

As a result, snippets show up above/after the schema tag but not inside of it, it should be the opposite !

panoply commented 1 year ago

Good catch.

Maybe it is worth releasing the embedded regions capability to override this. Let's discuss more in discord.

panoply commented 1 year ago

Let's make some action here. I am contemplating moving straight toward embedded region support which would make schema snippets obsolete as the JSON Schema Stores would be used in-place. The resulting effect would be this:

https://user-images.githubusercontent.com/7041324/198382398-be65049d-058f-47f5-a861-cd4cbae1bd5f.mp4

The hurdles here is that implementing this may require moving to Liquify as the Language Server is required in order to provide the JSON Language Features. I need to investigate if this can achieved without moving directly to Server/Client logic as it would double the workload considering this already possible in Liquify.

If going ahead here, integrating completions for section.settings.* and block.settings.* is a no brainer. Essentially providing completions in accordance with the JSON contained in section {% schema %} tags, for example:

{% # The "foo" completion will be made available upon typing a "." and the "info" will supply description %}
{{ section.settings.foo }}

{% schema %}
  {
    "name": "Foo",
    "tag": "section",
    "settings": [
      {
        "type": "text",
        "id": "action",
        "label": "Action",
        "info": "This description will be applied to the completion"
      }
    ]
  }
{% endschema %}

The logic for this already exists but would need some testing. My main hesitation of making it available are:

  1. I wanted to hold off until Liquify
  2. I don't want to integrate a Server just yet

The counter arguments to this are as follows:

  1. It is a highly desirable feature
  2. It would be nice to test the feature to offset any issues in Liquify
  3. It's fucking dope.

Thoughts / ideas and use cases greatly appreciated.

panoply commented 1 year ago

This will be supported in 3.2.0 and in addition section.* schema tag completions. The {% schema %} tag is parsed and persisted to provide your values defined in the schema JSON structure. It uses the info property value for descriptions.

Example:

https://user-images.githubusercontent.com/7041324/206410605-d322411d-bdd0-46d7-bd07-ac5331dccd5d.mov

panoply commented 1 year ago

Shipping tomorrow 🚢