diff --git a/.changes/unreleased/ENHANCEMENTS-20240827-150104.yaml b/.changes/unreleased/ENHANCEMENTS-20240827-150104.yaml new file mode 100644 index 0000000000..ff78651558 --- /dev/null +++ b/.changes/unreleased/ENHANCEMENTS-20240827-150104.yaml @@ -0,0 +1,6 @@ +kind: ENHANCEMENTS +body: Remove static snippets +time: 2024-08-27T15:01:04.207532-04:00 +custom: + Issue: "1830" + Repository: vscode-terraform diff --git a/README.md b/README.md index 0f0442972e..065d18c4cd 100644 --- a/README.md +++ b/README.md @@ -106,14 +106,9 @@ See the [Formatting](#formatting) Configuration section for information on how t ### Code Snippets -The extension provides several snippets to accelerate adding Terraform code to your configuration files: - -- `fore` - For Each -- `module` - Module -- `output` - Output -- `provisioner` - Provisioner -- `vare` - Empty variable -- `varm` - Map Variable +The extension provides context aware snippets to accelerate adding Terraform code to your configuration files. + +Combined with `editor.suggest.preview` and `terraform.experimentalFeatures.prefillRequiredFields`, the extension can suggest completions for all Terraform language constructs. ### HCP Terraform Integration diff --git a/package.json b/package.json index 2f07eb57ed..934864950a 100644 --- a/package.json +++ b/package.json @@ -315,12 +315,6 @@ } } }, - "snippets": [ - { - "language": "terraform", - "path": "./snippets/terraform.json" - } - ], "configuration": [ { "title": "General", diff --git a/snippets/terraform.json b/snippets/terraform.json deleted file mode 100644 index 5bad321736..0000000000 --- a/snippets/terraform.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "For Each": { - "prefix": "fore", - "body": [ - "for_each = {", - "\t${1:key} = \"${2:value}\"", - "}" - ], - "description": "The for_each meta-argument accepts a map or a set of strings, and creates an instance for each item in that map or set." - }, - "Module": { - "prefix": "module", - "body": [ - "module \"${1:name}\" {", - "\tsource = \"$2\"", - "\t$3", - "}" - ] - }, - "Output": { - "prefix": "output", - "body": [ - "output \"${1:name}\" {", - "\tvalue = \"$2\"", - "}" - ] - }, - "Provisioner": { - "prefix": "provisioner", - "body": [ - "provisioner \"${1:name}\" {", - "${2}", - "}" - ], - "description": "Provisioners can be used to model specific actions on the local machine or on a remote machine in order to prepare servers or other infrastructure objects for service." - }, - "Empty variable": { - "prefix": "vare", - "body": [ - "variable \"${1:name}\" {", - "\ttype = ${2|string,number,bool|}", - "\t${3:description = \"${4:(optional) describe your variable}\"}", - "}" - ], - "description": "Variable (empty)" - }, - "Map variable": { - "prefix": "varm", - "body": [ - "variable \"${1:name}\" {", - "\ttype = map(${2|string,number,bool|})", - "\t${3:description = \"${4:(optional) describe your variable}\"}", - "\tdefault = {", - "\t\t${5:key1} = \"${6:val1}\"", - "\t\t${7:key2} = \"${8:val2}\"", - "\t}", - "}" - ], - "description": "Variable (map)" - } -} \ No newline at end of file diff --git a/src/test/integration/basics/completion.test.ts b/src/test/integration/basics/completion.test.ts index 6653a92cb6..f0c2f253a7 100644 --- a/src/test/integration/basics/completion.test.ts +++ b/src/test/integration/basics/completion.test.ts @@ -7,15 +7,6 @@ import * as vscode from 'vscode'; import { assert } from 'chai'; import { activateExtension, getDocUri, open, testCompletion } from '../../helper'; -const snippets = [ - new vscode.CompletionItem({ label: 'fore', description: 'For Each' }, vscode.CompletionItemKind.Snippet), - new vscode.CompletionItem({ label: 'module', description: 'Module' }, vscode.CompletionItemKind.Snippet), - new vscode.CompletionItem({ label: 'output', description: 'Output' }, vscode.CompletionItemKind.Snippet), - new vscode.CompletionItem({ label: 'provisioner', description: 'Provisioner' }, vscode.CompletionItemKind.Snippet), - new vscode.CompletionItem({ label: 'vare', description: 'Empty variable' }, vscode.CompletionItemKind.Snippet), - new vscode.CompletionItem({ label: 'varm', description: 'Map variable' }, vscode.CompletionItemKind.Snippet), -]; - suite('completion', () => { suite('root document completion', function suite() { const docUri = getDocUri('empty.tf'); @@ -49,7 +40,7 @@ suite('completion', () => { new vscode.CompletionItem('terraform', vscode.CompletionItemKind.Class), new vscode.CompletionItem('variable', vscode.CompletionItemKind.Class), ]; - expected.push(...snippets); + await testCompletion(docUri, new vscode.Position(0, 0), { items: expected, }); @@ -83,7 +74,6 @@ suite('completion', () => { new vscode.CompletionItem('providers', vscode.CompletionItemKind.Property), new vscode.CompletionItem('version', vscode.CompletionItemKind.Property), ]; - expected.push(...snippets); await testCompletion(docUri, new vscode.Position(21, 0), { items: expected, @@ -97,10 +87,6 @@ suite('completion', () => { new vscode.CompletionItem('"./compute"', vscode.CompletionItemKind.Text), ]; - if (vscode.version <= '1.82.3') { - expected.push(...snippets); - } - // module "compute" { // source = "./compute" // ^ @@ -166,7 +152,7 @@ suite('completion', () => { new vscode.CompletionItem('project', vscode.CompletionItemKind.Property), new vscode.CompletionItem('region', vscode.CompletionItemKind.Property), ]; - expected.push(...snippets); + await testCompletion(docUri, new vscode.Position(1, 0), { items: expected, });