From 8e291211dc5930363d3ad146f8c05594f40a8211 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Tue, 10 Aug 2021 04:00:34 -0500 Subject: [PATCH 1/2] fix: configs not working for the deprecated pyls --- lib/main.js | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/lib/main.js b/lib/main.js index bb598094..e076ec5f 100644 --- a/lib/main.js +++ b/lib/main.js @@ -45,8 +45,21 @@ class PythonLanguageClient extends AutoLanguageClient { return "ide-python" } + getPyLs() { + if (this.pyls === undefined) { + let pyls = atom.config.get("ide-python.pyls") || "pylsp" + // check if it exists + if (whichSync(pyls, { nothrow: true }) === null) { + pyls = "pyls" + } + // cache + this.pyls = pyls + } + return this.pyls + } + mapConfigurationObject(configuration) { - const lsp = configuration.pyls || "pylsp" + const lsp = this.getPyLs() return { [lsp]: { configurationSources: configuration.pylsConfigurationSources, @@ -71,13 +84,7 @@ class PythonLanguageClient extends AutoLanguageClient { this.python = replacePipEnvPathVar(pythonBin, venvPath) - let pyls = atom.config.get("ide-python.pyls") || "pylsp" - // check if it exists - if (whichSync(pyls, { nothrow: true }) === null) { - pyls = "pyls" - } - - const childProcess = super.spawn(this.python, ["-m", pyls], { + const childProcess = super.spawn(this.python, ["-m", this.getPyLs()], { cwd: projectPath, env: pylsEnvironment, }) From 902102bed3e675bb00007eec94ef7af5d6059d7c Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Tue, 10 Aug 2021 04:12:40 -0500 Subject: [PATCH 2/2] fix: fallback to the other pyls if one doesn't exist --- lib/main.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/main.js b/lib/main.js index e076ec5f..0b61cd62 100644 --- a/lib/main.js +++ b/lib/main.js @@ -50,7 +50,8 @@ class PythonLanguageClient extends AutoLanguageClient { let pyls = atom.config.get("ide-python.pyls") || "pylsp" // check if it exists if (whichSync(pyls, { nothrow: true }) === null) { - pyls = "pyls" + // use the other one if it doesn't exist + pyls = pyls === "pylsp" ? "pyls" : "pylsp" } // cache this.pyls = pyls