diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..e5f7013 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,2 @@ +node_modules/**/* +out/**/* \ No newline at end of file diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..196d453 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,7 @@ +{ + "trailingComma": "es5", + "semi": true, + "singleQuote": false, + "endOfLine": "lf", + "arrowParens": "always" +} diff --git a/package-lock.json b/package-lock.json index c82e5b6..e4897c6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,6 +20,7 @@ "eslint": "^7.15.0", "glob": "^7.1.6", "mocha": "^10.1.0", + "prettier": "^3.0.1", "ts-loader": "^8.0.13", "typescript": "^4.1.2", "vsce": "^2.15.0", @@ -3388,6 +3389,21 @@ "node": ">= 0.8.0" } }, + "node_modules/prettier": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.0.1.tgz", + "integrity": "sha512-fcOWSnnpCrovBsmFZIGIy9UqK2FaI7Hqax+DIO0A9UxeVoY4iweyaFjS5TavZN97Hfehph0nhsZnjlVKzEQSrQ==", + "dev": true, + "bin": { + "prettier": "bin/prettier.cjs" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, "node_modules/process-nextick-args": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", diff --git a/package.json b/package.json index e377f15..a91b20b 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,8 @@ "compile": "webpack --mode development", "compile-watch": "webpack --mode development --watch", "test-compile": "tsc -p ./", - "vscode:package": "vsce package" + "vscode:package": "vsce package", + "format": "prettier ./**/*.ts --write --cache" }, "devDependencies": { "@types/glob": "^7.1.3", @@ -80,6 +81,7 @@ "eslint": "^7.15.0", "glob": "^7.1.6", "mocha": "^10.1.0", + "prettier": "^3.0.1", "ts-loader": "^8.0.13", "typescript": "^4.1.2", "vsce": "^2.15.0", diff --git a/src/extension.ts b/src/extension.ts index d274071..5ac506b 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -21,24 +21,27 @@ export function activate(context: vscode.ExtensionContext) { onEnterRules, }); - const restartCommand = vscode.commands.registerCommand(GleamCommands.RestartServer, async () => { - if (!client) { - vscode.window.showErrorMessage("gleam client not found"); - return; - } + const restartCommand = vscode.commands.registerCommand( + GleamCommands.RestartServer, + async () => { + if (!client) { + vscode.window.showErrorMessage("gleam client not found"); + return; + } - try { - if (client.isRunning()) { - await client.restart(); + try { + if (client.isRunning()) { + await client.restart(); - vscode.window.showInformationMessage("gleam server restarted."); - } else { - await client.start(); + vscode.window.showInformationMessage("gleam server restarted."); + } else { + await client.start(); + } + } catch (err) { + client.error("Restarting client failed", err, "force"); } - } catch (err) { - client.error("Restarting client failed", err, "force"); } - }); + ); context.subscriptions.push(restartCommand);