Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dummdidumm committed Nov 6, 2023
1 parent b78e7f3 commit 2195aa7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Snippets allow you to create reusable UI blocks you can render with the {@render
They also function as slot props for components.
`,
render: `\`{@render ...}\`\\
Render a snippet with the given parameters.
Renders a snippet with the given parameters.
`,
html:
`\`{@html ...}\`\\
Expand Down Expand Up @@ -87,9 +87,11 @@ It accepts a comma-separated list of variable names (not arbitrary expressions).
https://svelte.dev/docs#template-syntax-debug
`,
const: `\`{@const ...}\`\\
TODO
Defines a local constant}\\
#### Usage:
\`{@const a = b + c}\`\\
\\
https://svelte.dev/docs/special-tags#const
`
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ function getCompletionsWithRegardToTriggerCharacter(
return createCompletionItems([
{ tag: 'html', label: 'html' },
{ tag: 'debug', label: 'debug' },
{ tag: 'const', label: 'const' }
{ tag: 'const', label: 'const' },
{ tag: 'render', label: 'render' }
]);
}

Expand All @@ -143,7 +144,8 @@ function getCompletionsWithRegardToTriggerCharacter(
label: 'await then',
insertText: 'await $1 then $2}\n\t$3\n{/await'
},
{ tag: 'key', label: 'key', insertText: 'key $1}\n\t$2\n{/key' }
{ tag: 'key', label: 'key', insertText: 'key $1}\n\t$2\n{/key' },
{ tag: 'snippet', label: 'snippet', insertText: 'snippet $1($2)}\n\t$3\n{/snippet' }
]);
}

Expand Down Expand Up @@ -207,6 +209,7 @@ function showCompletionWithRegardsToOpenedTags(
ifOpen: CompletionList;
awaitOpen: CompletionList;
keyOpen?: CompletionList;
snippetOpen?: CompletionList;
},
svelteDoc: SvelteDocument,
offset: number
Expand All @@ -220,6 +223,8 @@ function showCompletionWithRegardsToOpenedTags(
return on.awaitOpen;
case 'key':
return on?.keyOpen ?? null;
case 'snippet':
return on.snippetOpen ?? null;
default:
return null;
}
Expand Down
4 changes: 4 additions & 0 deletions packages/svelte-vscode/snippets/svelte.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,9 @@
"key": {
"body": ["{#key ${1:key}}", "\t$TM_SELECTED_TEXT$0", "{/key}"],
"description": "key block"
},
"snippet": {
"body": ["{#snippet ${1:snippet}(${2:parameter})}", "\t$TM_SELECTED_TEXT$0", "{/snippet}"],
"description": "snippet block"
}
}

0 comments on commit 2195aa7

Please sign in to comment.