diff --git a/.prettierignore b/.prettierignore index a45ebb6b..c4a7ba68 100644 --- a/.prettierignore +++ b/.prettierignore @@ -7,3 +7,4 @@ coverage build dist VendorLib +.mypy_cache diff --git a/lib/main.js b/lib/main.js index 43298080..b8a1a1f0 100644 --- a/lib/main.js +++ b/lib/main.js @@ -1,5 +1,5 @@ const { shell } = require("electron") -const execFileSync = require("child_process").execFileSync +const whichSync = require("which").sync const { AutoLanguageClient } = require("atom-languageclient") const { detectVirtualEnv, detectPipEnv, replacePipEnvPathVar, sanitizeConfig } = require("./utils") @@ -53,10 +53,7 @@ class PythonLanguageClient extends AutoLanguageClient { let pyls = atom.config.get("ide-python.pyls") || "pylsp" // check if it exists - try { - execFileSync(pyls, ["--help"], { stdio: "inherit" }) - } catch (e) { - console.error(e) + if (whichSync(pyls, { nothrow: true }) === null) { pyls = "pyls" } const childProcess = super.spawn(python, ["-m", pyls], { diff --git a/package.json b/package.json index e4542a70..dc181bdb 100644 --- a/package.json +++ b/package.json @@ -67,6 +67,7 @@ "untildify": "3.0.2", "vscode-debugadapter": "1.24.0", "vscode-debugprotocol": "1.24.0", + "which": "^2.0.2", "xml2js": "0.4.17" }, "devDependencies": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 853cf510..88ab2340 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -35,6 +35,7 @@ specifiers: untildify: 3.0.2 vscode-debugadapter: 1.24.0 vscode-debugprotocol: 1.24.0 + which: ^2.0.2 xml2js: 0.4.17 dependencies: @@ -64,6 +65,7 @@ dependencies: untildify: 3.0.2 vscode-debugadapter: 1.24.0 vscode-debugprotocol: 1.24.0 + which: 2.0.2 xml2js: 0.4.17 devDependencies: @@ -2698,7 +2700,6 @@ packages: /isexe/2.0.0: resolution: {integrity: sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=} - dev: true /isobject/2.1.0: resolution: {integrity: sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=} @@ -3906,7 +3907,6 @@ packages: hasBin: true dependencies: isexe: 2.0.0 - dev: true /window-size/0.1.4: resolution: {integrity: sha1-+OGqHuWlPsW/FR/6CXQqatdpeHY=}