Skip to content

Commit 025c4ec

Browse files
authored
v0.8.0 (#22)
* Add new vueuse snippets * Add and modify vue script snippets * Remove reactivity transform * Read filename on pinia store define * Read filename on composable define * Define bunch of new template snippets and some js snippets * chore: release v0.8.0
1 parent 7ca0706 commit 025c4ec

File tree

12 files changed

+500
-255
lines changed

12 files changed

+500
-255
lines changed

README.md

Lines changed: 310 additions & 135 deletions
Large diffs are not rendered by default.

deno.lock

Lines changed: 27 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "vue-nuxt-snippets",
33
"displayName": "Vue Ecosystem Snippets",
44
"description": "Snippets for the modern Vue ecosystem - including Nuxt 3, Pinia, VueUse, Vue Router & Vue Macros.",
5-
"version": "0.7.0",
5+
"version": "0.8.0",
66
"license": "MIT",
77
"icon": "assets/icon.png",
88
"author": {

src/models/app.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export type XSnippetDefinition = SnippetDefinition<XSnippetDict>;
2222
export type VscSnippetDefinition = SnippetDefinition<VscSnippetDict>;
2323

2424
export type SnippetVariant<T> = {
25-
label: string;
25+
label?: string;
2626
description?: string;
2727
fileName: string;
2828
snippetDefinitions: T[];

src/snippets/pinia/script.ts

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export const script: XSnippetDefinition = {
1010
body: [
1111
"import { defineStore } from 'pinia'",
1212
"",
13-
"export const use${1/(.*)/${1:/capitalize}/} = defineStore('${2:key}', () => {",
13+
"export const use${TM_FILENAME_BASE/^(.*)$/${1:/pascalcase}/}Store = defineStore('$TM_FILENAME_BASE', () => {",
1414
"\t$0",
1515
"\t",
1616
"\treturn {",
@@ -25,18 +25,14 @@ export const script: XSnippetDefinition = {
2525
body: [
2626
"import { defineStore } from 'pinia'",
2727
"",
28-
"export const use${1/(.*)/${1:/capitalize}/} = defineStore('${2:key}', {",
29-
"\tstate: () => ({",
30-
"\t\t",
31-
"\t}),",
32-
"\tgetters: {",
33-
"\t\t",
34-
"\t},",
35-
"\tactions: {",
36-
"\t\t",
37-
"\t},",
28+
"export const use${TM_FILENAME_BASE/^(.*)$/${1:/pascalcase}/}Store = defineStore('$TM_FILENAME_BASE', {",
29+
" state: () => ({",
30+
" $0",
31+
" }),",
32+
" getters: {},",
33+
" actions: {},",
3834
"})",
39-
"",
35+
""
4036
],
4137
},
4238
vuseStore: {

src/snippets/vue/app.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import { XSnippetVariant } from "../../models/app.ts";
22

3+
import { codeSnippets } from "./code-snippets.ts";
34
import { script } from "./script.ts";
5+
import { style } from "./style.ts";
46
import { template } from "./template.ts";
57
import { vueSfc } from "./vue.ts";
6-
import { style } from "./style.ts";
7-
import { codeSnippets } from "./code-snippets.ts";
8-
import { reactivityTransform } from "./reactivity-transform.ts";
98

109
export const vue: XSnippetVariant[] = [
1110
{
@@ -22,6 +21,6 @@ export const vue: XSnippetVariant[] = [
2221
},
2322
{
2423
fileName: "vue-script",
25-
snippetDefinitions: [script, codeSnippets, reactivityTransform],
24+
snippetDefinitions: [script, codeSnippets],
2625
},
2726
];

src/snippets/vue/code-snippets.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export const codeSnippets: XSnippetDefinition = {
99
vcomposable: {
1010
name: "Vue define composable",
1111
body: [
12-
"export const use${1/(.*)/${1:/capitalize}/} = () => {",
12+
"export const use${1/(.*)/${1:/pascalcase}/} = () => {",
1313
"\t$0",
1414
"\t",
1515
"\treturn {",
@@ -20,6 +20,20 @@ export const codeSnippets: XSnippetDefinition = {
2020
],
2121
alt: ["vdc"],
2222
},
23+
"vcomposable:file": {
24+
name: "Vue define composable in file",
25+
body: [
26+
"export const use${TM_FILENAME_BASE/^(.*)$/${1:/pascalcase}/} = () => {",
27+
"\t$0",
28+
"\t",
29+
"\treturn {",
30+
"\t\t",
31+
"\t}",
32+
"}",
33+
"",
34+
],
35+
alt: ["vdcf"],
36+
},
2337
vuse: {
2438
name: "Use composable",
2539
body: "const ${2:$1} = use${1/(.*)/${1:/capitalize}/}($3)",

src/snippets/vue/reactivity-transform.ts

Lines changed: 0 additions & 39 deletions
This file was deleted.

src/snippets/vue/script.ts

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export const script: XSnippetDefinition = {
2727
body: "const ${1:name} = computed<$2>(() => $3)",
2828
alt: ["vct"],
2929
},
30-
"vcomputed-gs": {
30+
"vcomputed:gs": {
3131
name: "Vue computed (get/set)",
3232
body: [
3333
"const ${1:name} = computed({",
@@ -48,25 +48,25 @@ export const script: XSnippetDefinition = {
4848
name: "Vue reactive (typed)",
4949
body: "const ${1:name}: ${2:type} = reactive({$3})",
5050
},
51+
vshallowRef: {
52+
name: "Vue shallowRef",
53+
body: "const ${1:name} = shallowRef($2)",
54+
},
5155
vtoRef: {
5256
name: "Vue toRef",
53-
body: "const ${1:name} = toRef(${2:object}, '$3')",
57+
body: "toRef(${1:props}, '$2')",
5458
},
5559
vtoRefs: {
5660
name: "Vue toRefs",
57-
body: "const ${1:name} = toRefs(${2:object})",
58-
},
59-
vshallowRef: {
60-
name: "Vue shallowRef",
61-
body: "const ${1:name} = shallowRef($2)",
61+
body: "toRefs(${1:props})",
6262
},
6363
vunref: {
6464
name: "Vue unref",
65-
body: "const ${1:unwrapped} = unref($2)",
65+
body: "unref($1)",
6666
},
6767
vreadonly: {
6868
name: "Vue readonly",
69-
body: "const ${1:copy} = readonly(${2:object})",
69+
body: "readonly(${1:object})",
7070
},
7171
"vref:elem": {
7272
name: "Vue element ref",
@@ -109,6 +109,7 @@ export const script: XSnippetDefinition = {
109109
"\tconsole.log('$1:', $2)",
110110
"})",
111111
],
112+
alt: ["vwl"],
112113
},
113114
vprops: {
114115
name: "Vue defineProps",
@@ -120,23 +121,27 @@ export const script: XSnippetDefinition = {
120121
"${1:const props = }withDefaults(defineProps<${2:Props}>(), {\n\t$0\n})",
121122
],
122123
},
124+
"vprops:js": {
125+
name: "Vue defineProps without TS",
126+
body: "${1:const props = }defineProps({\n\t$2\n})",
127+
},
123128
vemits: {
124129
name: "Vue defineEmits",
125-
body: "${1:const emit = }defineEmits(['$2'])",
126-
},
127-
"vemits:ts": {
128-
name: "Vue defineEmits (typed)",
129130
body: [
130131
"${1:const emit = }defineEmits<{",
131-
"\t(e: '${2:click}', ${3:payload}: ${4:string}): void,$5",
132+
"\t${2:click}: [${3:payload}: ${4:string}],$5",
132133
"}>()",
133134
],
134135
},
135-
"vemits:new": {
136-
name: "Vue defineEmits (new syntax)",
136+
"vemits:alt": {
137+
name: "Vue defineEmits without TS",
138+
body: "${1:const emit = }defineEmits(['$2'])",
139+
},
140+
"vemits:old": {
141+
name: "Vue defineEmits (old syntax)",
137142
body: [
138143
"${1:const emit = }defineEmits<{",
139-
"\t${2:click}: [${3:payload}: ${4:string}],$5",
144+
"\t(e: '${2:click}', ${3:payload}: ${4:string}): void,$5",
140145
"}>()",
141146
],
142147
},
@@ -146,7 +151,7 @@ export const script: XSnippetDefinition = {
146151
},
147152
vemit: {
148153
name: "Vue emit event",
149-
body: "emit('$1', $2)",
154+
body: "emit('$1'$2)",
150155
},
151156
vexpose: {
152157
name: "Vue defineExpose",
@@ -218,17 +223,16 @@ export const script: XSnippetDefinition = {
218223
},
219224
vinject: {
220225
name: "Vue inject",
221-
body: "const ${1:value} = inject(${2:key})",
226+
body: "const ${1:value} = inject(${2:key})",
227+
},
228+
"vinject:ts": {
229+
name: "Vue inject (typed)",
230+
body: "const ${1:value} = inject<${2:string}>(${3:key})",
222231
},
223232
"vinject:default": {
224233
name: "Vue inject with default",
225234
body: "const ${1:value} = inject(${2:key}, ${3:defaultValue})",
226235
},
227-
"vinject:ts": {
228-
name: "Vue inject (typed)",
229-
body:
230-
"const ${1:value} = inject<${2:string}}>(${3:key}, ${4:defaultValue})",
231-
},
232236
"vinjectkey": {
233237
name: "Vue injection key",
234238
body: "const ${1:key} = Symbol('$2') as InjectionKey<${3:string}>",
@@ -244,6 +248,7 @@ export const script: XSnippetDefinition = {
244248
vimport: {
245249
name: "Import from vue",
246250
body: "import { $1 } from 'vue'",
251+
alt: ["vim"],
247252
},
248253
},
249254
};

0 commit comments

Comments
 (0)