[LSP] Fix vue + snippets

This commit is contained in:
Admin 2025-04-17 18:48:28 +02:00
parent 410c563e96
commit 3a7a2fdcd9
3 changed files with 65 additions and 5 deletions

View File

@ -157,7 +157,7 @@ return {
name = "@vue/typescript-plugin", name = "@vue/typescript-plugin",
-- location = "/usr/lib/node_modules/@vue/typescript-plugin", -- location = "/usr/lib/node_modules/@vue/typescript-plugin",
location = volar_path, location = volar_path,
languages = { "javascript", "typescript", "vue" }, languages = { "vue" },
}, },
}, },
}, },

View File

@ -41,7 +41,7 @@
"fetch from other url": { "fetch from other url": {
"prefix": "remoteURL", "prefix": "remoteURL",
"body": [ "body": [
"localStorage.getItem( 'url' ) + '/$1'", "localStorage.getItem( 'url' ) + '/$1'"
], ],
"description": "remote URL fetching (get from base address from local storage)" "description": "remote URL fetching (get from base address from local storage)"
}, },
@ -90,4 +90,4 @@
"} );" "} );"
] ]
} }
} }

View File

@ -7,5 +7,65 @@
"</script>" "</script>"
], ],
"description": "Setup the basic structure of a class in JS" "description": "Setup the basic structure of a class in JS"
} },
} "JSAsync": {
"prefix": "jsAsync",
"body": "(async () => {\n$1\n} ) ();"
},
"JSpromiseReturnFunc": {
"prefix": "jsPromise",
"body": "function $1 () {\n\treturn new Promise( ( resolve, reject ) => {\n\t$2\n\t} );\n}"
},
"fetch from other url": {
"prefix": "remoteURL",
"body": [
"localStorage.getItem( 'url' ) + '/$1'"
],
"description": "remote URL fetching (get from base address from local storage)"
},
"fetch post": {
"prefix": "fetchPost",
"body": [
"const fetchOptions = {",
"\tmethod: 'post',",
"\tbody: JSON.stringify( $1 ),",
"\tcredentials: 'include',",
"\theaders: {",
"\t\t'Content-Type': 'application/json',",
"\t\t'charset': 'utf-8'",
"\t}",
"};",
"fetch( $2, fetchOptions ).then( res => {",
"\tif ( res.status === 200 ) {",
"\t\tres.json().then( json => {",
"\t\t\t$3",
"\t\t} );",
"\t}",
"} );",
"$4"
],
"description": "POST request using fetch"
},
"fetch get": {
"prefix": "fetchGet",
"body": [
"fetch( $2, { credentials: 'include' } ).then( res => {",
"\tif ( res.status === 200 ) {",
"\t\tres.json().then( json => {",
"\t\t\t$3",
"\t\t} );",
"\t}",
"} );",
"$4"
],
"description": "POST request using fetch"
},
"promise": {
"prefix": "promise",
"body": [
"return new Promise( ( resolve, reject ) => {",
"\t",
"} );"
]
}
}