From 3a7a2fdcd99270dd7bfe7a90901c73f0d5c39ffb Mon Sep 17 00:00:00 2001 From: Janis Hutz Date: Thu, 17 Apr 2025 18:48:28 +0200 Subject: [PATCH] [LSP] Fix vue + snippets --- nvim/lua/plugins/lsp/lspconfig.lua | 2 +- nvim/snippets/snippets/typescript.json | 4 +- nvim/snippets/snippets/vue.json | 64 +++++++++++++++++++++++++- 3 files changed, 65 insertions(+), 5 deletions(-) diff --git a/nvim/lua/plugins/lsp/lspconfig.lua b/nvim/lua/plugins/lsp/lspconfig.lua index 2676da7..234a98a 100755 --- a/nvim/lua/plugins/lsp/lspconfig.lua +++ b/nvim/lua/plugins/lsp/lspconfig.lua @@ -157,7 +157,7 @@ return { name = "@vue/typescript-plugin", -- location = "/usr/lib/node_modules/@vue/typescript-plugin", location = volar_path, - languages = { "javascript", "typescript", "vue" }, + languages = { "vue" }, }, }, }, diff --git a/nvim/snippets/snippets/typescript.json b/nvim/snippets/snippets/typescript.json index 2b83a66..24ccb29 100755 --- a/nvim/snippets/snippets/typescript.json +++ b/nvim/snippets/snippets/typescript.json @@ -41,7 +41,7 @@ "fetch from other url": { "prefix": "remoteURL", "body": [ - "localStorage.getItem( 'url' ) + '/$1'", + "localStorage.getItem( 'url' ) + '/$1'" ], "description": "remote URL fetching (get from base address from local storage)" }, @@ -90,4 +90,4 @@ "} );" ] } -} \ No newline at end of file +} diff --git a/nvim/snippets/snippets/vue.json b/nvim/snippets/snippets/vue.json index 9571d25..1fb123d 100755 --- a/nvim/snippets/snippets/vue.json +++ b/nvim/snippets/snippets/vue.json @@ -7,5 +7,65 @@ "" ], "description": "Setup the basic structure of a class in JS" - } -} \ No newline at end of file + }, + "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", + "} );" + ] + } +}