From a7e4d2bff999562c569726e3e9a6264fc8013857 Mon Sep 17 00:00:00 2001 From: BubbleTg Date: Thu, 16 Jun 2022 22:37:49 +0800 Subject: [PATCH] feat: 0.2.8 Vue support --- package.json | 4 ++- src/extension.js | 66 ++++++++++++------------------------------------ 2 files changed, 19 insertions(+), 51 deletions(-) diff --git a/package.json b/package.json index 623edf3..4740b1d 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "parameter-hints", "displayName": "Parameter Hints", "description": "Automatic parameter hints", - "version": "0.2.7", + "version": "0.2.8", "preview": true, "icon": "icon.png", "repository": { @@ -48,6 +48,7 @@ "description": "Enable Languages", "default": [ "php", + "vue", "javascript", "typescript", "javascriptreact", @@ -55,6 +56,7 @@ ], "enum": [ "php", + "vue", "javascript", "typescript", "javascriptreact", diff --git a/src/extension.js b/src/extension.js index 10e2c9d..d7ea941 100644 --- a/src/extension.js +++ b/src/extension.js @@ -37,61 +37,27 @@ function activate(context) { } timeout = setTimeout(() => { if (editor && (isEnabled() || force)) { - if (languagesEnabled().includes("php") && editor.document.languageId === 'php') { - currentRunner = runner(phpRunner, editor, hints => { - if (hints !== false && isEnabled()) { - if (hints.length) { - editor.setDecorations(hintDecorationType, hints); - } else { - editor.setDecorations(hintDecorationType, [new vscode.Range(0, 0, 0, 0)]); - } - + const runnerHints = hints => { + if (hints !== false && isEnabled()) { + if (hints.length) { + editor.setDecorations(hintDecorationType, hints); + } else { + editor.setDecorations(hintDecorationType, [new vscode.Range(0, 0, 0, 0)]); } - }) + } + } + if (languagesEnabled().includes("php") && editor.document.languageId === 'php') { + currentRunner = runner(phpRunner, editor, runnerHints ) + } else if (languagesEnabled().includes("vue") && editor.document.languageId === 'vue') { + currentRunner = runner(typescriptRunner, editor, runnerHints) } else if (languagesEnabled().includes("typescript") && editor.document.languageId === 'typescript') { - currentRunner = runner(typescriptRunner, editor, hints => { - if (hints !== false && isEnabled()) { - if (hints.length) { - editor.setDecorations(hintDecorationType, hints); - } else { - editor.setDecorations(hintDecorationType, [new vscode.Range(0, 0, 0, 0)]); - } - - } - }, { language: ts.ScriptKind.TS }) + currentRunner = runner(typescriptRunner, editor, runnerHints, { language: ts.ScriptKind.TS }) } else if (languagesEnabled().includes("typescriptreact") && editor.document.languageId === 'typescriptreact') { - currentRunner = runner(typescriptRunner, editor, hints => { - if (hints !== false && isEnabled()) { - if (hints.length) { - editor.setDecorations(hintDecorationType, hints); - } else { - editor.setDecorations(hintDecorationType, [new vscode.Range(0, 0, 0, 0)]); - } - - } - }, { language: ts.ScriptKind.TSX }) + currentRunner = runner(typescriptRunner, editor, runnerHints, { language: ts.ScriptKind.TSX }) } else if (languagesEnabled().includes("javascript") && editor.document.languageId === 'javascript') { - currentRunner = runner(typescriptRunner, editor, hints => { - if (hints !== false && isEnabled()) { - if (hints.length) { - editor.setDecorations(hintDecorationType, hints); - } else { - editor.setDecorations(hintDecorationType, [new vscode.Range(0, 0, 0, 0)]); - } - - } - }, { language: ts.ScriptKind.JS }) + currentRunner = runner(typescriptRunner, editor, runnerHints, { language: ts.ScriptKind.JS }) } else if (languagesEnabled().includes("javascriptreact") && editor.document.languageId === 'javascriptreact') { - currentRunner = runner(typescriptRunner, editor, hints => { - if (hints !== false && isEnabled()) { - if (hints.length) { - editor.setDecorations(hintDecorationType, hints); - } else { - editor.setDecorations(hintDecorationType, [new vscode.Range(0, 0, 0, 0)]); - } - - } - }, { language: ts.ScriptKind.JSX }) + currentRunner = runner(typescriptRunner, editor, runnerHints, { language: ts.ScriptKind.JSX }) } } }, time);