Skip to content

Commit 01dfc6c

Browse files
committed
feat: default to python-lsp-server (pylsp) instead of pyls
1 parent ad4d166 commit 01dfc6c

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

lib/main.js

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const { shell } = require("electron")
2+
const execFileSync = require("child_process").execFileSync
23
const { AutoLanguageClient } = require("atom-languageclient")
34
const { detectVirtualEnv, detectPipEnv, replacePipEnvPathVar, sanitizeConfig } = require("./utils")
45

@@ -49,7 +50,15 @@ class PythonLanguageClient extends AutoLanguageClient {
4950
pylsEnvironment["VIRTUAL_ENV"] = venvPath
5051
}
5152
const python = replacePipEnvPathVar(atom.config.get("ide-python.python"), venvPath)
52-
const pyls = atom.config.get("ide-python.pyls") || "pyls"
53+
54+
let pyls = atom.config.get("ide-python.pyls") || "pylsp"
55+
// check if it exists
56+
try {
57+
execFileSync(pyls, ["--help"], { stdio: "inherit" })
58+
} catch (e) {
59+
console.error(e)
60+
pyls = "pyls"
61+
}
5362
const childProcess = super.spawn(python, ["-m", pyls], {
5463
cwd: projectPath,
5564
env: pylsEnvironment,
@@ -83,7 +92,7 @@ class PythonLanguageClient extends AutoLanguageClient {
8392
},
8493
],
8594
description:
86-
"Make sure to install `pyls` 0.19 or newer by running:\n" +
95+
"Make sure to install `pylsp` 0.19 or newer by running:\n" +
8796
"```\n" +
8897
`${python} -m pip install 'python-lsp-server[all]'\n` +
8998
`${python} -m pip install git+https://github.com/tomv564/pyls-mypy.git\n` +

package.json

+6
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,12 @@
9393
"default": "python",
9494
"description": "Absolute path of your Python binary. This is used to launch the Python language server. Make sure to install `pyls` for this version of Python. Changes will take effect after a restart of the language server. Use `$PIPENV_PATH/bin/python` if you want to use the pipenv path of your project"
9595
},
96+
"pyls-path": {
97+
"title": "Path to pyls executable",
98+
"order": 2,
99+
"type": "string",
100+
"default": "pylsp"
101+
},
96102
"pylsConfigurationSources": {
97103
"order": 2,
98104
"type": "array",

0 commit comments

Comments
 (0)