From 4328529f8a6ec63a01cbd77c321cbbc5834f0bc1 Mon Sep 17 00:00:00 2001 From: Nikolas Savvidis Date: Tue, 13 Dec 2022 10:42:42 +0100 Subject: [PATCH 01/10] fixes #135 support locale schema completions Co-Authored-By: Cyril Canete <9353672+ccanete@users.noreply.github.com> --- src/parse/schema.ts | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/parse/schema.ts b/src/parse/schema.ts index 83a8cee3..a7fd6543 100644 --- a/src/parse/schema.ts +++ b/src/parse/schema.ts @@ -8,7 +8,7 @@ export const schema = { type: 'object', properties: { content: { - type: 'string', + type: [ 'string', 'object' ], title: 'Content', description: 'Textual content for the header title.' } @@ -18,7 +18,7 @@ export const schema = { type: 'object', properties: { placeholder: { - type: 'string', + type: [ 'string', 'object' ], title: 'Placeholder', description: 'A placeholder value' } @@ -48,15 +48,15 @@ export const schema = { additionalProperties: false, properties: { value: { - type: 'string', + type: [ 'string', 'object' ], description: 'The value of the select options. This will be used as the output' }, label: { - type: 'string', + type: [ 'string', 'object' ], description: 'A label to render to the theme editor' }, group: { - type: 'string', + type: [ 'string', 'object' ], description: 'An optional attribute you can add to each option to create option groups in the drop-down.' } } @@ -110,10 +110,10 @@ export const schema = { additionalProperties: false, properties: { value: { - type: 'string' + type: [ 'string', 'object' ] }, label: { - type: 'string' + type: [ 'string', 'object' ] } } } @@ -136,7 +136,7 @@ export const schema = { } }, placeholder: { - type: 'string', + type: [ 'string', 'object' ], title: 'Placeholder', description: 'A placeholder value' } @@ -347,7 +347,7 @@ export const schema = { }, info: { title: 'Info', - type: 'string', + type: [ 'string', 'object' ], description: "Additional information about the setting. Use sparingly, as it's better to use only informative labels whenever you can." } }, @@ -507,7 +507,7 @@ export const schema = { name: { title: 'Name', description: 'The name attribute determines the section title that is shown in the theme editor.', - type: 'string' + type: [ 'string', 'object' ] }, class: { title: 'Class', @@ -587,7 +587,7 @@ export const schema = { name: { title: 'Name', description: 'The preset name, which will show in the Add section portion of the theme editor.', - type: 'string' + type: [ 'string', 'object' ] }, settings: { type: 'object', @@ -615,7 +615,7 @@ export const schema = { name: { title: 'Name', description: 'The default name, which will show in the Add section portion of the theme editor.', - type: 'string' + type: [ 'string', 'object' ] }, settings: { type: 'object', From 40d33fa41ce35e77955f4569071ee57e721d7b72 Mon Sep 17 00:00:00 2001 From: Nikolas Savvidis Date: Tue, 13 Dec 2022 12:59:38 +0100 Subject: [PATCH 02/10] supports unit locales Co-Authored-By: Cyril Canete <9353672+ccanete@users.noreply.github.com> --- src/parse/schema.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/parse/schema.ts b/src/parse/schema.ts index a7fd6543..c5a0d416 100644 --- a/src/parse/schema.ts +++ b/src/parse/schema.ts @@ -89,7 +89,7 @@ export const schema = { description: 'The maximum number of steps' }, unit: { - type: 'string', + type: [ 'string', 'object' ], title: 'Max', maxLength: 3, description: 'The unit of measure label. For example, you could use sec for seconds, or px for pixels.' From 7078d3708587df271a0053d9bc7cc29553a54ccd Mon Sep 17 00:00:00 2001 From: Nikolas Savvidis Date: Tue, 13 Dec 2022 14:22:54 +0100 Subject: [PATCH 03/10] support locales completions in schema files --- src/parse/schema.ts | 255 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 229 insertions(+), 26 deletions(-) diff --git a/src/parse/schema.ts b/src/parse/schema.ts index c5a0d416..5d993feb 100644 --- a/src/parse/schema.ts +++ b/src/parse/schema.ts @@ -3,6 +3,128 @@ export const schema = { $id: 'shopify-section-schema', version: 1.1, definitions: { + languages: { + type: 'object', + description: 'Locales', + properties: { + af: { + type: 'string', + description: 'Afrikaans' + }, + bs: { + type: 'string', + description: 'Bosnian (bosanski/босански)' + }, + cs: { + type: 'string', + description: 'Czech (čeština)' + }, + da: { + type: 'string', + description: 'Danish (dansk)' + }, + de: { + type: 'string', + description: 'German (Deutsch)' + }, + el: { + type: 'string', + description: 'Greek (ελληνικά)' + }, + en: { + type: 'string', + description: 'English' + }, + es: { + type: 'string', + description: 'Spanish (español)' + }, + fi: { + type: 'string', + description: ' Finnish (suomi)' + }, + fr: { + type: 'string', + description: 'French (français)' + }, + fy: { + type: 'string', + description: 'Frisian (Frysk)' + }, + he: { + type: 'string', + description: 'Hebrew (עברית)' + }, + hi: { + type: 'string', + description: 'Hindi (हिंदी)' + }, + hu: { + type: 'string', + description: 'Hungarian (magyar)' + }, + hy: { + type: 'string', + description: 'Armenian (Հայերեն)' + }, + id: { + type: 'string', + description: 'Indonesian (Bahasa Indonesia)' + }, + is: { + type: 'string', + description: 'Icelandic (íslenska)' + }, + lv: { + type: 'string', + description: 'Latvian (latviešu)' + }, + nl: { + type: 'string', + description: 'Dutch (Nederlands)' + }, + no: { + type: 'string', + description: 'Norwegian (norsk)' + }, + pl: { + type: 'string', + description: 'Polish (polski)' + }, + it: { + type: 'string', + description: 'Italian (italiano)' + }, + ja: { + type: 'string', + description: 'Japanese (日本語)' + }, + ko: { + type: 'string', + description: 'Korean (한국어/韓國語)' + }, + lb: { + type: 'string', + description: 'Luxembourgish (Lëtzebuergesch)' + }, + ru: { + type: 'string', + description: 'Russian (русский)' + }, + sv: { + type: 'string', + description: 'Swedish' + }, + zh: { + type: 'string', + description: 'Chinese (中文)' + }, + uk: { + type: 'string', + description: 'Ukrainian (українська)' + } + } + }, content: { required: [ 'content' ], type: 'object', @@ -18,9 +140,17 @@ export const schema = { type: 'object', properties: { placeholder: { - type: [ 'string', 'object' ], title: 'Placeholder', - description: 'A placeholder value' + description: 'A placeholder value', + default: '', + oneOf: [ + { + type: 'string' + }, + { + $ref: '#/definitions/languages' + } + ] } } }, @@ -48,16 +178,34 @@ export const schema = { additionalProperties: false, properties: { value: { - type: [ 'string', 'object' ], + type: 'string', description: 'The value of the select options. This will be used as the output' }, label: { - type: [ 'string', 'object' ], - description: 'A label to render to the theme editor' + title: 'Label', + description: 'A label to render to the theme editor', + default: '', + oneOf: [ + { + type: 'string' + }, + { + $ref: '#/definitions/languages' + } + ] }, group: { - type: [ 'string', 'object' ], - description: 'An optional attribute you can add to each option to create option groups in the drop-down.' + title: 'Group', + description: 'An optional attribute you can add to each option to create option groups in the drop-down.', + default: '', + oneOf: [ + { + type: 'string' + }, + { + $ref: '#/definitions/languages' + } + ] } } } @@ -89,10 +237,17 @@ export const schema = { description: 'The maximum number of steps' }, unit: { - type: [ 'string', 'object' ], - title: 'Max', - maxLength: 3, - description: 'The unit of measure label. For example, you could use sec for seconds, or px for pixels.' + title: 'Unit', + description: 'The unit of measure label. For example, you could use sec for seconds, or px for pixels.', + default: '', + oneOf: [ + { + type: 'string' + }, + { + $ref: '#/definitions/languages' + } + ] } } }, @@ -110,10 +265,20 @@ export const schema = { additionalProperties: false, properties: { value: { - type: [ 'string', 'object' ] + type: 'string' }, label: { - type: [ 'string', 'object' ] + title: 'Label', + description: 'Radio Label', + default: '', + oneOf: [ + { + type: 'string' + }, + { + $ref: '#/definitions/languages' + } + ] } } } @@ -136,9 +301,7 @@ export const schema = { } }, placeholder: { - type: [ 'string', 'object' ], - title: 'Placeholder', - description: 'A placeholder value' + $ref: '#/definitions/languages' } } }, @@ -336,19 +499,36 @@ export const schema = { description: 'The unique name for this setting. The id is exposed to the liquid templates via the settings object. It must only contain alphanumeric characters, underscores, and dashes.' }, label: { - type: [ 'string', 'object' ], title: 'Label', - description: 'A label for this setting.' + description: 'A label for this setting.', + default: '', + oneOf: [ + { + type: 'string' + }, + { + $ref: '#/definitions/languages' + } + ] }, default: { type: [ 'string', 'number', 'boolean' ], title: 'Default', + default: '', description: 'A value to which the setting can default.' }, info: { title: 'Info', - type: [ 'string', 'object' ], - description: "Additional information about the setting. Use sparingly, as it's better to use only informative labels whenever you can." + description: "Additional information about the setting. Use sparingly, as it's better to use only informative labels whenever you can.", + default: '', + oneOf: [ + { + type: 'string' + }, + { + $ref: '#/definitions/languages' + } + ] } }, allOf: [ @@ -411,7 +591,6 @@ export const schema = { $ref: '#/definitions/limit' } }, - { if: { required: [ 'type' ], @@ -476,9 +655,17 @@ export const schema = { required: [ 'name', 'type' ], properties: { name: { - type: [ 'string', 'object' ], - title: 'Block Type', - description: 'The block name which is used as the merchants label' + title: 'Block Name', + description: 'The block name which is used as the merchants label', + default: '', + oneOf: [ + { + type: 'string' + }, + { + $ref: '#/definitions/languages' + } + ] }, type: { type: 'string', @@ -507,7 +694,15 @@ export const schema = { name: { title: 'Name', description: 'The name attribute determines the section title that is shown in the theme editor.', - type: [ 'string', 'object' ] + default: '', + oneOf: [ + { + type: 'string' + }, + { + $ref: '#/definitions/languages' + } + ] }, class: { title: 'Class', @@ -587,7 +782,15 @@ export const schema = { name: { title: 'Name', description: 'The preset name, which will show in the Add section portion of the theme editor.', - type: [ 'string', 'object' ] + default: '', + oneOf: [ + { + type: 'string' + }, + { + $ref: '#/definitions/languages' + } + ] }, settings: { type: 'object', From b4373afa4249491f3a80a3bf8c3104c64ea6a719 Mon Sep 17 00:00:00 2001 From: Nikolas Savvidis Date: Tue, 13 Dec 2022 14:23:06 +0100 Subject: [PATCH 04/10] ensure liquid document --- src/providers/CompletionProvider.ts | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/providers/CompletionProvider.ts b/src/providers/CompletionProvider.ts index 830a2548..dc86a178 100644 --- a/src/providers/CompletionProvider.ts +++ b/src/providers/CompletionProvider.ts @@ -77,22 +77,24 @@ export function CompletionProvider ( if (trigger === Char.DQO || trigger === Char.COL) { - const isSchema = parseSchema(content, offset); + if (document.languageId === 'liquid') { - if (isSchema !== false && isSchema.within) { + const isSchema = parseSchema(content, offset); - const schema = service.doParse(document, position, isSchema); - const items = await service.doCompletions(schema); + if (isSchema !== false && isSchema.within) { - return getSchemaCompletions( - trigger === Char.DQO ? 1 : 0, - position.line, - position.character, - items as any - ); + const schema = service.doParse(document, position, isSchema); + const items = await service.doCompletions(schema); - } + return getSchemaCompletions( + trigger === Char.DQO ? 1 : 0, + position.line, + position.character, + items as any + ); + } + } } if (trigger === Char.PER) { From 60a0d92c014e9dc016294597e67c1da1927b215e Mon Sep 17 00:00:00 2001 From: Nikolas Savvidis Date: Tue, 13 Dec 2022 14:23:13 +0100 Subject: [PATCH 05/10] ensure liquid document --- src/service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/service.ts b/src/service.ts index ac3dc12c..f1a86ef5 100644 --- a/src/service.ts +++ b/src/service.ts @@ -290,7 +290,7 @@ export class VSCodeLiquid extends CommandPalette { */ public async onDidChangeTextDocument ({ document }: TextDocumentChangeEvent) { - if (this.engine === 'shopify' && this.canValidate.schema === true) { + if (this.engine === 'shopify' && this.canValidate.schema === true && document.languageId === 'liquid') { const schema = getSchema(document); From e30556ff6400e524e11b33fbf133c7abf3c866b4 Mon Sep 17 00:00:00 2001 From: Nikolas Savvidis Date: Tue, 13 Dec 2022 14:25:53 +0100 Subject: [PATCH 06/10] remove schema snippets --- snippets/schema.json | 365 ------------------------------------------- 1 file changed, 365 deletions(-) delete mode 100644 snippets/schema.json diff --git a/snippets/schema.json b/snippets/schema.json deleted file mode 100644 index 7b6874a0..00000000 --- a/snippets/schema.json +++ /dev/null @@ -1,365 +0,0 @@ -{ - "schema: name": { - "scope": "liquid", - "description": "Schema property: \"name\"", - "prefix": "\"settings", - "body": "\"name\": \"$1\"$0" - }, - "schema: tag": { - "scope": "liquid", - "description": "Schema property: \"tag\"", - "prefix": "\"tag", - "body": "\"tag\": \"${1|article,aside,div,footer,header,section|}\",${2:,}" - }, - "schema: class": { - "scope": "liquid", - "description": "Schema property: \"class\"", - "prefix": "\"class", - "body": "\"class\": \"$1\"${2:,}$0" - }, - "schema: settings": { - "scope": "liquid", - "prefix": "\"settings", - "description": "Schema property: \"settings\"", - "body": ["\"settings\": [", "\t$0", "]"] - }, - "schema: max blocks": { - "scope": "liquid", - "description": "Schema property: \"max_blocks\"", - "prefix": "schema: max_blocks", - "body": "\"max_blocks\": ${1:5}${2:,}$0" - }, - "schema: type": { - "scope": "liquid", - "description": "Schema settings property: \"type\"", - "prefix": "schema: type", - "body": "\"type\": \"${2|header,paragraph,text,textarea,image_picker,radio,select,checkbox,range,color,font_picker,collection,product,blog,page,link_list,url,video_url,richtext,html,article|}\"" - }, - "schema: placeholder": { - "scope": "liquid", - "description": "Schema settings property: \"placeholder\"", - "prefix": "schema: placeholder", - "body": "\"placeholder\": \"$1\"${2:,}$0" - }, - "schema: info": { - "scope": "liquid", - "description": "Schema settings property: \"info\"", - "prefix": "schema: info", - "body": "\"info\": \"$1\"${2:,}$0" - }, - "schema: default": { - "scope": "liquid", - "description": "Schema property: \"default\"", - "prefix": "schema: default", - "body": "\"default\": \"$1\"${2:,}$0" - }, - "schema: header": { - "scope": "liquid", - "description": "Schema input setting: \"header\"", - "prefix": "schema: header", - "body": [ - "{", - "\t\"type\": \"header\",", - "\t\"content\": \"$1\"${2:,\n\t\"info\": \"$3\"}${4:,}", - "}${5:,}$0" - ] - }, - "schema: paragraph": { - "scope": "liquid", - "description": "Schema input setting: \"paragraph\"", - "prefix": "schema: paragraph", - "body": [ - "{", - "\t\"type\": \"paragraph\",", - "\t\"content\": \"$1\"", - "}${2:,}$0" - ] - }, - "schema: text": { - "scope": "liquid", - "description": "Schema input setting: \"text\"", - "prefix": "schema: text", - "body": [ - "{", - "\t\"type\": \"text\",", - "\t\"id\": \"${1:id}\",", - "\t\"label\": \"${2:label}\"${3:,\n\t\"default\": \"$4\"}${5:,\n\t\"info\": \"$6\"}${7:,\n\t\"placeholder\": \"$8\"}", - "}${9:,}$0" - ] - }, - "schema: textarea": { - "scope": "liquid", - "description": "Schema input setting: \"textarea\"", - "prefix": "schema: textarea", - "body": [ - "{", - "\t\"type\": \"textarea\",", - "\t\"id\": \"${1:id}\",", - "\t\"label\": \"${2:label}\"${3:,\n\t\"default\": \"$4\"}${5:,\n\t\"info\": \"$6\"}${7:,\n\t\"placeholder\": \"$8\"}", - "}${9:,}$0" - ] - }, - "schema: richtext": { - "scope": "liquid", - "description": "Schema input setting: \"richtext\"", - "prefix": "schema: richtext", - "body": [ - "{", - "\t\"type\": \"richtext\",", - "\t\"id\": \"${1:id}\",", - "\t\"label\": \"${2:label}\"${3:,\n\t\"default\": \"$4\"}${5:,\n\t\"info\": \"$6\"}", - "}${7:,}$0" - ] - }, - "schema: select": { - "scope": "liquid", - "description": "Schema input setting: \"select\"", - "prefix": "schema: select", - "body": [ - "{", - "\t\"type\": \"select\",", - "\t\"id\": \"${1:id}\",", - "\t\"label\": \"${2:label}\",", - "\t\"options\": [", - "\t\t{", - "\t\t\t\"value\": \"$3\",", - "\t\t\t\"label\": \"$4\"${5:,\n\t\t\t\"group\": \"$6\"}", - "\t\t}", - "\t]", - "}${7:,}$0" - ] - }, - "schema: radio": { - "scope": "liquid", - "description": "Schema input setting: \"radio\"", - "prefix": "schema: radio", - "body": [ - "{", - "\t\"type\": \"radio\",", - "\t\"id\": \"${1:id}\",", - "\t\"label\": \"${2:label}\",${3:\n\t\"default\": \"$4\",}${5:\n\t\"info\": \"$6\",}", - "\t\"options\": [", - "\t\t{", - "\t\t\t\"value\": \"$7\",", - "\t\t\t\"label\": \"$8\"", - "\t\t}", - "\t]", - "}${9:,}$0" - ] - }, - "schema: option": { - "scope": "liquid", - "description": "Schema input select/radio option setting", - "prefix": "schema: select/radio option", - "body": [ - "{", - "\t\"value\": \"$1\",", - "\t\"label\": \"$2\"${3:,\n\t\"group\": \"$4\"}", - "}${5:,}$0" - ] - }, - "schema: checkbox": { - "scope": "liquid", - "description": "Schema input setting: \"checkbox\"", - "prefix": "schema: checkbox", - "body": [ - "{", - "\t\"type\": \"checkbox\",", - "\t\"id\": \"${1:id}\",", - "\t\"label\": \"${2:label}\",", - "\t\"default\": ${3|true,false|}", - "}" - ] - }, - "schema: number": { - "scope": "liquid", - "prefix": "schema: number", - "body": [ - "{", - "\t\"type\": \"number\",", - "\t\"id\": \"${1:id}\",", - "\t\"label\": \"${1:label}\",", - "\t\"default\": ${1:20},", - "\t\"placeholder\": \"${1:placeholder}\"", - "}" - ], - "description": "schema: number" - }, - "schema: range": { - "scope": "liquid", - "description": "Schema input setting: \"range\"", - "prefix": "schema: range", - "body": [ - "{", - "\t\"type\": \"range\",", - "\t\"id\": \"${1:id}\",", - "\t\"label\": \"${2:label}\",", - "\t\"unit\": \"${3:unit}\",", - "\t\"min\": ${4:1},", - "\t\"max\": ${5:10},", - "\t\"step\": ${6:1},", - "\t\"default\": ${7:1}", - "}${8:,}$0" - ] - }, - "schema: image picker": { - "scope": "liquid", - "description": "Schema input setting: \"image_picker\"", - "prefix": "schema: image_picker", - "body": [ - "{", - "\t\"type\": \"image_picker\",", - "\t\"id\": \"${1:id}\",", - "\t\"label\": \"${2:label}\"", - "}${3:,}$0" - ] - }, - "schema: link list": { - "scope": "liquid", - "description": "Schema input setting: \"link_list\"", - "prefix": "schema: link_list", - "body": [ - "{", - "\t\"type\": \"link_list\",", - "\t\"id\": \"${1:id}\",", - "\t\"label\": \"${2:label}\"${3:,\n\t\"default\": \"$4\"}${5:,\n\t\"info\": \"$6\"}", - "}${7:,}$0" - ] - }, - "schema: color": { - "scope": "liquid", - "description": "Schema input setting: \"color\"", - "prefix": "schema: color", - "body": [ - "{", - "\t\"type\": \"color\",", - "\t\"id\": \"${1:id}\",", - "\t\"label\": \"${2:label}\"${3:,\n\t\"default\": \"#$4\"}${5:,\n\t\"info\": \"$6\"}", - "}${7:,}$0" - ] - }, - "schema: font picker": { - "scope": "liquid", - "description": "Schema input setting: \"font_picker\"", - "prefix": "schema: font_picker", - "body": [ - "{", - "\t\"type\": \"font_picker\",", - "\t\"id\": \"${1:id}\",", - "\t\"label\": \"${2:label}\"${3:,\n\t\"default\": \"#$4\"}${5:,\n\t\"info\": \"$6\"}", - "}${7:,}$0" - ] - }, - "schema: collection": { - "scope": "liquid", - "description": "Schema input setting: \"collection\"", - "prefix": "schema: collection", - "body": [ - "{", - "\t\"type\": \"collection\",", - "\t\"id\": \"${1:id}\",", - "\t\"label\": \"${2:label}\"${3:,\n\t\"info\": \"$4\"}", - "}${5:,}$0" - ] - }, - "schema: product": { - "scope": "liquid", - "description": "Schema input setting: \"product\"", - "prefix": "schema: product", - "body": [ - "{", - "\t\"type\": \"product\",", - "\t\"id\": \"${1:id}\",", - "\t\"label\": \"${2:label}\"${3:,\n\t\"info\": \"$4\"}", - "}${5:,}$0" - ] - }, - "schema: blog": { - "scope": "liquid", - "description": "Schema input setting: \"blog\"", - "prefix": "schema: blog", - "body": [ - "{", - "\t\"type\": \"blog\",", - "\t\"id\": \"${1:id}\",", - "\t\"label\": \"${2:label}\"${3:,\n\t\"info\": \"$4\"}", - "}${5:,}$0" - ] - }, - "schema: article": { - "scope": "liquid", - "description": "Schema input setting: \"article\"", - "prefix": "schema: article", - "body": [ - "{", - "\t\"type\": \"article\",", - "\t\"id\": \"${1:id}\",", - "\t\"label\": \"${2:label}\"${3:,\n\t\"info\": \"$4\"}", - "}${5:,}$0" - ] - }, - "schema: page": { - "scope": "liquid", - "description": "Schema input setting: \"page\"", - "prefix": "schema: page", - "body": [ - "{", - "\t\"type\": \"page\",", - "\t\"id\": \"${1:id}\",", - "\t\"label\": \"${2:label}\"${3:,\n\t\"info\": \"$4\"}", - "}${5:,}$0" - ] - }, - "schema: url": { - "scope": "liquid", - "description": "Schema input setting: \"url\"", - "prefix": "schema: url", - "body": [ - "{", - "\t\"type\": \"url\",", - "\t\"id\": \"${1:id}\",", - "\t\"label\": \"${2:label}\"${3:,\n\t\"default\": \"$4\"}", - "}${5:,}$0" - ] - }, - "schema: video url": { - "scope": "liquid", - "description": "Schema input setting: \"video_url\"", - "prefix": "schema: video_url", - "body": [ - "{", - "\t\"type\": \"video_url\",", - "\t\"id\": \"$1\",", - "\t\"accept\": [", - "\t\t${2:\"youtube\"}${4:,}${3:\n\t\t\"vimeo\"}", - "\t],", - "\t\"label\": \"${5:label}\"${6:,\n\t\"default\": \"$7\"}${8:,\n\t\"info\": \"$9\"}${10:,\n\t\"placeholder\": \"$11\"}", - "}${12:,}$0" - ] - }, - "schema: html": { - "scope": "liquid", - "description": "Schema input setting: \"html\"", - "prefix": "schema: html", - "body": [ - "{", - "\t\"type\": \"html\",", - "\t\"id\": \"${1:id}\",", - "\t\"label\": \"${2:label}\"${3:,\n\t\"info\": \"$4\"}", - "}${5:,}$0" - ] - }, - "schema: presets": { - "scope": "liquid", - "description": "Schema property: \"presets\"", - "prefix": "schema: presets", - "body": [ - "\"presets\": [", - "\t{", - "\t\t\"category\": \"$1\",", - "\t\t\"name\":\"$2\"", - "\t}", - "]${4:,}$0" - ] - } -} From 9d8c767bbb11e8879df834f208446c6eab9bcd4e Mon Sep 17 00:00:00 2001 From: Nikolas Savvidis Date: Tue, 13 Dec 2022 14:27:07 +0100 Subject: [PATCH 07/10] remove trims from tag snippets leverage the formatting rule `delimiterTrims` for this capability. Co-Authored-By: Cyril Canete <9353672+ccanete@users.noreply.github.com> --- snippets/tags.json | 178 +++++++++++++++++++++------------------------ 1 file changed, 83 insertions(+), 95 deletions(-) diff --git a/snippets/tags.json b/snippets/tags.json index 4b5188a7..000e4e74 100755 --- a/snippets/tags.json +++ b/snippets/tags.json @@ -1,238 +1,226 @@ { - "Jekyll frontmatter": { - "prefix": "---", + "frontmatter": { + "prefix": "frontmatter", "description": "Frontmatter", "body": ["---", "$2", "---"] }, "if": { "prefix": "if", "body": [ - "{%${1:-} if ${2:condition} ${1:-}%}", + "{% if ${1:condition} %}", "\t$3", - "{%${1:-} endif ${1:-}%}" + "{% endif %}" ] }, "else": { "prefix": "else", - "body": ["{%${1:-} else ${1:-}%}", "\t"] + "body": ["{% else %}", "\t"] }, "elsif": { "prefix": "elsif", - "body": ["{%${1:-} elsif ${2:condition} ${1:-}%}", "\t"] + "body": ["{% elsif ${1:condition} %}", "\t"] }, "if, elsif": { "prefix": "if elsif", "body": [ - "{%${1:-} if ${2:condition} ${1:-}%}", - "\t$3", - "{%${1:-} elsif ${4:condition} ${1:-}%}", - "\t$5", - "{%${1:-} endif ${1:-}%}" + "{% if ${1:condition} %}", + "\t$2", + "{% elsif ${3:condition} %}", + "\t$4", + "{% endif %}" ] }, "if, else": { "prefix": "if else", "body": [ - "{%${1:-} if ${2:condition} ${1:-}%}", + "{% if ${1:condition} %}", + "\t$2", + "{% else %}", "\t$3", - "{%${1:-} else ${1:-}%}", - "\t$4", - "{%${1:-} endif ${1:-}%}" + "{% endif %}" ] }, "unless": { "prefix": "unless", "body": [ - "{%${1:-} unless ${2:condition} ${1:-}%}", + "{% unless ${1:condition} %}", + "\t$2", + "{% endunless %}" + ] + }, + "unless, else": { + "prefix": "unless else", + "body": [ + "{% unless ${1:condition} %}", + "\t$2", + "{% else %}", "\t$3", - "{%${1:-} endunless ${1:-}%}" + "{% endunless %}" ] }, "case, else": { "prefix": "case", "body": [ - "{%${1:-} case ${2:variable} ${1:-}%}", - "\t{%${1:-} when ${3:condition} ${1:-}%}", + "{% case ${1:variable} %}", + "\t{% when ${2:condition} %}", + "\t\t$3", + "\t{% else %}", "\t\t$4", - "\t{%${1:-} else ${1:-}%}", - "\t\t$5", - "{%${1:-} endcase ${1:-}%}" + "{% endcase %}" ] }, "when": { "prefix": "when", "description": "Control flow tag: when", - "body": ["{%${1:-} when ${2:condition} ${1:-}%}", "$0"] + "body": ["{% when ${1:condition} %}", "$0"] }, "cycle": { "prefix": "cycle", "description": "Iteration tag: cycle", - "body": [ - "{%${1:-} cycle '${2:odd}', '${3:even}' ${1:-}%}" - ] + "body": ["{% cycle '${1:odd}', '${2:even}' %}"] }, - "cycle group": { - "prefix": "cyclegroup", + "cycle, group": { + "prefix": "cycle group", "description": "Iteration tag: cycle group", "body": [ - "{%${1:-} cycle '${2:group name}': '${3:odd}', '${4:even}' ${1:-}%}" + "{% cycle '${1:group name}': '${2:odd}', '${3:even}' %}" ] }, "for": { "prefix": "for", "body": [ - "{%${1:-} for ${2:item} in ${3:collection} ${1:-}%}", - "\t$4", - "{%${1:-} endfor ${1:-}%}" + "{% for ${1:item} in ${2:collection} %}", + "\t$3", + "{% endfor %}" ] }, - "limit": { - "prefix": "limit", - "body": ["limit: ${1:5}"] - }, - "offset": { - "prefix": "offset", - "body": ["offset: ${1:0}"] - }, - "reversed": { - "prefix": "reversed", - "body": ["reversed"] - }, "break": { "prefix": "break", - "body": ["{%${1:-} break ${1:-}%}"] + "body": ["{% break %}"] }, "continue": { "prefix": "continue", - "body": ["{%${1:-} continue ${1:-}%}"] + "body": ["{% continue %}"] }, "tablerow": { "prefix": "tablerow", "body": [ - "{%${1:-} tablerow ${2:item} in ${3:collection} cols: ${4:2} ${1:-}%}", + "{% tablerow ${1:item} in ${2:collection} cols: ${3:2} %}", "\t$5", - "{%${1:-} endtablerow ${1:-}%}" + "{% endtablerow %}" ] }, "assign": { "prefix": "assign", - "body": [ - "{%${1:-} assign ${2:variable} = ${3:value} ${1:-}%}" - ] + "body": ["{% assign ${1:variable} = ${2:value} %}"] }, "increment": { "prefix": "increment", - "body": ["{%${1:-} increment ${2:variable} ${1:-}%}"] + "body": ["{% increment ${1:variable} %}"] }, "decrement": { "prefix": "decrement", - "body": ["{%${1:-} decrement ${2:variable} ${1:-}%}"] + "body": ["{% decrement ${1:variable} %}"] }, "capture": { "prefix": "capture", "body": [ - "{%${1:-} capture ${2:variable} ${1:-}%}", - "\t$3", - "{%${1:-} endcapture ${1:-}%}" + "{% capture ${1:variable} %}", + "\t$2", + "{% endcapture %}" ] }, "liquid": { "prefix": "liquid", - "body": ["{%${1:-} liquid", "\t$2", "${1:-}%}"] + "body": ["{% liquid", "\t$1", "%}"] }, "render": { "prefix": "render", - "body": ["{%${1:-} render '${2:snippet}' ${1:-}%}"] + "body": ["{% render '${1:snippet}' %}"] + }, + "render, parameters": { + "prefix": "render", + "body": [ + "{% render '${1:snippet}', ${2:param}: ${3:value}" + ] }, "include": { "prefix": "include", - "body": ["{%${1:-} include '${2:snippet}' ${1:-}%}"] + "body": ["{% include '${1:snippet}' %}"] }, - "include with parameters": { + "include, parameters": { "prefix": "includewith", "body": [ - "{%${1:-} include '${2:snippet}', ${3:variable}: ${4:value} ${1:-}%}" + "{% include '${1:snippet}', ${2:param}: ${3:value} %}" ] }, "section": { "prefix": "section", - "body": ["{%${1:-} section '${2:section}' ${1:-}%}"] + "body": ["{% section '${1:section}' %}"] }, "raw": { "prefix": "raw", "description": "Theme tag: raw", - "body": [ - "{%${1:-} raw ${1:-}%}", - "\t$2", - "{%${1:-} endraw ${1:-}%}" - ] + "body": ["{% raw %}", "\t$1", "{% endraw %}"] }, "layout": { "prefix": "layout", - "body": ["{%${1:-} layout '${2:layout}' ${1:-}%}"] + "body": ["{% layout '${1:layout}' %}"] }, "form": { "prefix": "form", "body": [ - "{%${1:-} form '${2:product}', ${3:product} ${1:-}%}", + "{% form '${1:product}', ${2:product} %}", "\t$4", - "{%${1:-} endform ${1:-}%}" + "{% endform %}" ] }, "paginate": { "prefix": "paginate", "body": [ - "{%${1:-} paginate ${1:collection.products} by ${2:12} ${1:-}%}", - "\t{%${1:-} for ${3:product} in ${1:collection.products} ${1:-}%}", + "{% paginate ${1:collection.products} by ${2:12} %}", + "\t{% for ${3:product} in ${1:collection.products} %}", "\t\t$4", - "\t{%${1:-} endfor ${1:-}%}", - "{%${1:-} endpaginate ${1:-}%}" + "\t{% endfor %}", + "{% endpaginate %}" ] }, "schema": { "prefix": "schema", "body": [ - "{%${1:-} schema ${1:-}%}", - "{", - "\t$0", - "}", - "{%${1:-} endschema ${1:-}%}" + "{% schema %}", + "\t{", + "\t\t$1", + "\t}", + "{% endschema %}" ] }, "style": { "prefix": "style", - "body": [ - "{%${1:-} style ${1:-}%}", - "\t$0", - "{%${1:-} endstyle ${1:-}%}" - ] + "body": ["{% style %}", "\t$1", "{% endstyle %}"] }, "stylesheet": { "prefix": "stylesheet", "body": [ - "{%${1:-} stylesheet ${1:-}%}", - "\t$0", - "{%${1:-} endstylesheet ${1:-}%}" + "{% stylesheet %}", + "\t$1", + "{% endstylesheet %}" ] }, "javascript": { "prefix": "javascript", "body": [ - "{%${1:-} javascript ${1:-}%}", + "{% javascript %}", "\t$1", - "{%${1:-} endjavascript ${1:-}%}" + "{% endjavascript %}" ] }, "comment, inline": { "prefix": "#", - "body": ["{%${1:-} # $2 ${1:-}%}"] + "body": ["{% # $2 %}"] }, "comment, block": { "prefix": "comment", - "body": [ - "{%${1:-} comment ${1:-}%}", - "\t$0", - "{%${1:-} endcomment ${1:-}%}" - ] + "body": ["{% comment %}", "\t$0", "{% endcomment %}"] } } From cfc40e890a1fa528bdb0149b500f85027a1c54ae Mon Sep 17 00:00:00 2001 From: Nikolas Savvidis Date: Tue, 13 Dec 2022 14:27:36 +0100 Subject: [PATCH 08/10] tests --- test/.vscode/settings.json | 8 ++------ test/schema/no-process.json | 3 +++ test/sections/large-file.liquid | 12 +++++++++--- test/sections/sample.liquid | 7 ++++--- test/sections/schema.liquid | 24 ++++++++++++++---------- 5 files changed, 32 insertions(+), 22 deletions(-) create mode 100644 test/schema/no-process.json diff --git a/test/.vscode/settings.json b/test/.vscode/settings.json index aa995c8d..69ddae99 100644 --- a/test/.vscode/settings.json +++ b/test/.vscode/settings.json @@ -39,14 +39,10 @@ "[jsonc]": { "editor.defaultFormatter": "sissel.shopify-liquid", "editor.formatOnSave": true - - - }, - "[json]": { - "editor.defaultFormatter": "sissel.shopify-liquid" }, - "liquid.format.enable": true, + + "liquid.format.enable": false, "liquid.completion.tags": true, "liquid.completion.schema": true, "liquid.completion.filters": true, diff --git a/test/schema/no-process.json b/test/schema/no-process.json new file mode 100644 index 00000000..a72fed9b --- /dev/null +++ b/test/schema/no-process.json @@ -0,0 +1,3 @@ +{ + "example": "{% schema %} { \"\" } {% endschema %}" +} diff --git a/test/sections/large-file.liquid b/test/sections/large-file.liquid index 6946d736..4eb6c51b 100644 --- a/test/sections/large-file.liquid +++ b/test/sections/large-file.liquid @@ -2,6 +2,7 @@ Hello World {% endcomment %} +
+{% if condition %}{% endif %} + {% schema %} { "name": "Hero Slideshow", @@ -236,12 +239,15 @@ "blocks": [ { "type": "image", - "name": "Image", + "name": {}, "settings": [ { "type": "header", - "content": "Link", - "info": "Renders a href link on the hero image" + "content": "Link" + }, + { + "type": "header", + "content": "" }, { "type": "url", diff --git a/test/sections/sample.liquid b/test/sections/sample.liquid index 94fa0768..fd655fa8 100644 --- a/test/sections/sample.liquid +++ b/test/sections/sample.liquid @@ -200,7 +200,7 @@ { "type": "header", "content": "Caption", - "info": "Customize the text caption to be displayed on each collection image block" + "info": "Customize the text caption to be displayed on each collection image block", }, { "type": "radio", @@ -231,7 +231,7 @@ "type": "color", "label": "Text Colour", "id": "text_color", - "default": "#ffffff" + "default": "#ffffff", }, { "type": "color", @@ -267,7 +267,8 @@ "type": "image_picker", "id": "image", "label": "Image" - } + }, + ] }, { diff --git a/test/sections/schema.liquid b/test/sections/schema.liquid index aa6e6068..85c86cb4 100644 --- a/test/sections/schema.liquid +++ b/test/sections/schema.liquid @@ -1,5 +1,4 @@ -
+
foo @@ -7,13 +6,11 @@ {% if block.type == 'something' %} - {{ block.settings.xxxx }} + {{ block.settings }} - {% elsif block.type == "something" %} + {% elsif block.type == "xxx" %} - {{ block.settings.drive - | append: 'foo' - | capitalize }} + {{ block.settings.foooo }} {% render 'foo' , param: 1 @@ -34,7 +31,6 @@ "settings": [ { "type": "page", - "placeholder": "", "id": "", "default": 0 } @@ -50,7 +46,8 @@ "label": "foo" } ] - }, { + }, + { "name": "example", "type": "xxx", "settings": [ @@ -59,7 +56,14 @@ "id": "drive", "label": "car", "default": 0 - }, { + }, + { + "type": "text", + "id": "foooo", + "label": "Some Foooo", + "default": 0 + }, + { "default": 0, "type": "blog", "id": "foo", From 2cb8b887ac20874151e947063cdd2e9fe2a2cf82 Mon Sep 17 00:00:00 2001 From: Nikolas Savvidis Date: Tue, 13 Dec 2022 14:42:01 +0100 Subject: [PATCH 09/10] update readme --- readme.md | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/readme.md b/readme.md index a105327f..3b511e93 100644 --- a/readme.md +++ b/readme.md @@ -234,6 +234,9 @@ By default, it is assumed you are using vscode workspace/user settings. // Whether attributes should be indented each onto their own line "forceAttribute": false, + // Attribute force control and handling for value expressions + "valueForce": "intent", + // If text in the provided document code should be preserved "preserveText": true, @@ -479,7 +482,10 @@ liquid`{% if condition == true %} {{ object.prop }} {% endif %}`; # Schema IntelliSense -The current version (**v3.2^**) of the extension supports schema tag intelliSense capabilities. This is achieved on the client until the Liquify supersede and handling moves to the server using LSP. The feature drastically improves productivity for developers working with the Shopify Liquid variation. +As of version **v3.2^** this extension supports schema tag intelliSense capabilities. The feature drastically improves productivity for developers working with the Shopify Liquid variation. The contained JSON of `{% schema %}` tags support all the common capabilities and features for JSON. The contents of the schema tags (ie: the section data) is also made available to Liquid `section.settings` and `block.settings` object tags with respect to scope regions defined within control flow tags. + +> **Note**  +> This is achieved on the client until the Liquify supersede and handling moves to the server using LSP. ### Liquid Completions @@ -495,7 +501,7 @@ Liquid `section.*` object completions are provided in accordance with the conten ### JSON Completions -Embedded JSON contained within `{% schema %}` tags support completions in accordance with trigger characters. The JSON completions are made possible through Schema Stores maintained at [@liquify/schema](#). You can disable/enable JSON schema completions within your workspace settings configuration. +Embedded JSON contained within `{% schema %}` tags support completions in accordance with trigger characters. The JSON completions are made possible through Schema Stores maintained at [@liquify/schema](https://github.com/panoply/liquify-schema). You can disable/enable JSON schema completions within your workspace settings configuration. **Workspace Settings** @@ -519,7 +525,7 @@ In addition to JSON and Liquid completion support, schema JSON diagnostic valida # Completions -The extension supports completion capabilities. This is a **preview** feature and will be improved upon as the extension progresses to Liquify, as such the integration is elementary. Completions are similar to snippets but a little more refined. The completions will be invoked and made available depending on trigger characters and previous/surrounding character sequences. +The extension supports completion capabilities. This feature and will be improved upon as the extension progresses to Liquify, as such the integration is elementary. Completions are similar to snippets but a little more refined. The completions will be invoked and made available depending on trigger characters and previous/surrounding character sequences. ### Tags @@ -571,7 +577,7 @@ Liquid operator completions are made available within control flow tags such as ### Schema (Shopify) -Liquid `{% schema %}` embedded JSON tags support completions using JSON Schema Store files. Shopify schema tags is currently a **preview** feature. +Liquid `{% schema %}` embedded JSON tags support completions using JSON Schema Store files. **Workspace Settings** @@ -752,6 +758,7 @@ Below is the **default** rules. It is important to note that if the `liquid.form "preserveAttributes": false, "preserveText": false, "delimiterTrims": "preserve", + "valueForce": "intent", "ignoreScripts": false, "ignoreStyles": false }, @@ -798,11 +805,10 @@ Below is the **default** rules. It is important to note that if the `liquid.form # Snippets -Liquid snippets are supported in this extension. The filter and tag snippets provided were originally forked from [vscode-liquid-snippets](https://github.com/killalau/vscode-liquid-snippets) but have since changed a considerable amount. - -### Tag Snippets +Liquid snippets are supported in this extension. The filter and tag snippets were originally forked from [vscode-liquid-snippets](https://github.com/killalau/vscode-liquid-snippets). The snippets provided by this extension do not trim (`{%-`) based tag delimiters, you can instead leverage the markup formatting rule of `delimiterTrims` for controlling this. -Snippets made available leverage tab invoked "choices" for applying filter pipes `|` and delimiter whitespace dashes `-` within liquid tokens. In addition to the tags and filter snippets, section schema snippets are also supported which help users to quickly generate settings within Shopify theme `{% schema %}` tag blocks. +> **Note**  +> You can also invoke tag completions by typing `%` which will automatically trigger a completion list. # Extension Conflicts From ffb76984c8beb8b39b96ea46c224d6e2cb7ea374 Mon Sep 17 00:00:00 2001 From: Nikolas Savvidis Date: Tue, 13 Dec 2022 14:42:10 +0100 Subject: [PATCH 10/10] v3.2.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f4f988c3..a968cebc 100755 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "publisher": "sissel", "icon": "images/logo.png", "author": "Νίκος Σαβίδης ", - "version": "3.2.1", + "version": "3.2.2", "keywords": [ "liquid", "shopify",