diff --git a/editors/code/.vscodeignore b/editors/code/.vscodeignore index 4975496..7a75c78 100644 --- a/editors/code/.vscodeignore +++ b/editors/code/.vscodeignore @@ -6,4 +6,5 @@ **/tsconfig.base.json contributing.md .travis.yml -src/** \ No newline at end of file +src/** +node_modules \ No newline at end of file diff --git a/editors/code/package-lock.json b/editors/code/package-lock.json index b06eaf7..d9125d9 100644 --- a/editors/code/package-lock.json +++ b/editors/code/package-lock.json @@ -1,19 +1,21 @@ { "name": "circom-plus", - "version": "0.0.4", + "version": "0.0.6", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "circom-plus", - "version": "0.0.4", + "version": "0.0.6", "license": "MIT", "dependencies": { "@hpcc-js/wasm": "^2.13.0", + "@types/which": "^3.0.3", "anser": "^2.1.1", "d3": "^7.8.5", "d3-graphviz": "^5.0.2", - "vscode-languageclient": "^8.1.0" + "vscode-languageclient": "^8.1.0", + "which": "^4.0.0" }, "devDependencies": { "@tsconfig/strictest": "^2.0.1", @@ -632,6 +634,11 @@ "integrity": "sha512-emg7wdsTFzdi+elvoyoA+Q8keEautdQHyY5LNmHVM4PTpY8JgOTVADrGVyXGepJ6dVW2OS5/xnLUWh+nZxvdiA==", "dev": true }, + "node_modules/@types/which": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@types/which/-/which-3.0.3.tgz", + "integrity": "sha512-2C1+XoY0huExTbs8MQv1DuS5FS86+SEjdM9F/+GS61gg5Hqbtj8ZiDSx8MfWcyei907fIPbfPGCOrNUTnVHY1g==" + }, "node_modules/@typescript-eslint/eslint-plugin": { "version": "6.4.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.4.0.tgz", @@ -1368,6 +1375,27 @@ "node": ">= 8" } }, + "node_modules/cross-spawn/node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "dev": true + }, + "node_modules/cross-spawn/node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, "node_modules/css-select": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/css-select/-/css-select-5.1.0.tgz", @@ -2737,10 +2765,12 @@ "dev": true }, "node_modules/isexe": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", - "dev": true + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-3.1.1.tgz", + "integrity": "sha512-LpB/54B+/2J5hqQ7imZHfdU31OlgQqx7ZicVlkm9kzg9/w8GKLEcFfJl/t7DCEDueOyBAD6zCCwTO6Fzs0NoEQ==", + "engines": { + "node": ">=16" + } }, "node_modules/js-yaml": { "version": "4.1.0", @@ -3936,18 +3966,17 @@ "integrity": "sha512-SYU4z1dL0PyIMd4Vj8YOqFvHu7Hz/enbWtpfnVbJHU4Nd1YNYx8u0ennumc6h48GQNeOLxmwySmnADouT/AuZA==" }, "node_modules/which": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", - "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", - "dev": true, + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/which/-/which-4.0.0.tgz", + "integrity": "sha512-GlaYyEb07DPxYCKhKzplCWBJtvxZcZMrL+4UkrTSJHHPyZU4mYYTv3qaOe77H7EODLSSopAUFAc6W8U4yqvscg==", "dependencies": { - "isexe": "^2.0.0" + "isexe": "^3.1.1" }, "bin": { - "node-which": "bin/node-which" + "node-which": "bin/which.js" }, "engines": { - "node": ">= 8" + "node": "^16.13.0 || >=18.0.0" } }, "node_modules/wrap-ansi": { @@ -4384,6 +4413,11 @@ "integrity": "sha512-emg7wdsTFzdi+elvoyoA+Q8keEautdQHyY5LNmHVM4PTpY8JgOTVADrGVyXGepJ6dVW2OS5/xnLUWh+nZxvdiA==", "dev": true }, + "@types/which": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@types/which/-/which-3.0.3.tgz", + "integrity": "sha512-2C1+XoY0huExTbs8MQv1DuS5FS86+SEjdM9F/+GS61gg5Hqbtj8ZiDSx8MfWcyei907fIPbfPGCOrNUTnVHY1g==" + }, "@typescript-eslint/eslint-plugin": { "version": "6.4.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.4.0.tgz", @@ -4889,6 +4923,23 @@ "path-key": "^3.1.0", "shebang-command": "^2.0.0", "which": "^2.0.1" + }, + "dependencies": { + "isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "dev": true + }, + "which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "requires": { + "isexe": "^2.0.0" + } + } } }, "css-select": { @@ -5879,10 +5930,9 @@ "dev": true }, "isexe": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", - "dev": true + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-3.1.1.tgz", + "integrity": "sha512-LpB/54B+/2J5hqQ7imZHfdU31OlgQqx7ZicVlkm9kzg9/w8GKLEcFfJl/t7DCEDueOyBAD6zCCwTO6Fzs0NoEQ==" }, "js-yaml": { "version": "4.1.0", @@ -6780,12 +6830,11 @@ "integrity": "sha512-SYU4z1dL0PyIMd4Vj8YOqFvHu7Hz/enbWtpfnVbJHU4Nd1YNYx8u0ennumc6h48GQNeOLxmwySmnADouT/AuZA==" }, "which": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", - "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", - "dev": true, + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/which/-/which-4.0.0.tgz", + "integrity": "sha512-GlaYyEb07DPxYCKhKzplCWBJtvxZcZMrL+4UkrTSJHHPyZU4mYYTv3qaOe77H7EODLSSopAUFAc6W8U4yqvscg==", "requires": { - "isexe": "^2.0.0" + "isexe": "^3.1.1" } }, "wrap-ansi": { diff --git a/editors/code/package.json b/editors/code/package.json index 840bdc1..d796c1b 100644 --- a/editors/code/package.json +++ b/editors/code/package.json @@ -77,10 +77,12 @@ }, "dependencies": { "@hpcc-js/wasm": "^2.13.0", + "@types/which": "^3.0.3", "anser": "^2.1.1", "d3": "^7.8.5", "d3-graphviz": "^5.0.2", - "vscode-languageclient": "^8.1.0" + "vscode-languageclient": "^8.1.0", + "which": "^4.0.0" }, "devDependencies": { "@tsconfig/strictest": "^2.0.1", diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts index ab632e7..8a5b801 100644 --- a/editors/code/src/main.ts +++ b/editors/code/src/main.ts @@ -8,13 +8,28 @@ import { ServerOptions, Trace, } from "vscode-languageclient/node"; +import which = require("which"); let client: LanguageClient; export async function activate(context: ExtensionContext) { // If the extension is launched in debug mode then the debug server options are used // Otherwise the run options are used - const ccls_path = 'ccls'; + const platform = process.platform; + let ccls_path = "cclss"; + + const exist_ccls = await which(ccls_path, { nothrow: true }); + + if (exist_ccls === null) { + if (platform === "linux") { + ccls_path = path.join(__dirname, "../bin/ccls_linux"); + } else if (platform === "darwin") { + ccls_path = path.join(__dirname, "../bin/ccls_mac"); + } else { + window.showErrorMessage(`We don't support ${platform}`); + } + } + const run: Executable = { command: process.env.__CIRCOM_LSP_SERVER_DEBUG ?? ccls_path, };