Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,22 @@ 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) {
// use the other one if it doesn't exist
pyls = pyls === "pylsp" ? "pyls" : "pylsp"
}
// cache
this.pyls = pyls
}
return this.pyls
}

mapConfigurationObject(configuration) {
const lsp = configuration.pyls || "pylsp"
const lsp = this.getPyLs()
return {
[lsp]: {
configurationSources: configuration.pylsConfigurationSources,
Expand All @@ -71,13 +85,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,
})
Expand Down