Skip to content

Commit

Permalink
feat: default to python-lsp-server (pylsp) instead of pyls
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Jun 9, 2021
1 parent ad4d166 commit 01dfc6c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lib/main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const { shell } = require("electron")
const execFileSync = require("child_process").execFileSync
const { AutoLanguageClient } = require("atom-languageclient")
const { detectVirtualEnv, detectPipEnv, replacePipEnvPathVar, sanitizeConfig } = require("./utils")

Expand Down Expand Up @@ -49,7 +50,15 @@ class PythonLanguageClient extends AutoLanguageClient {
pylsEnvironment["VIRTUAL_ENV"] = venvPath
}
const python = replacePipEnvPathVar(atom.config.get("ide-python.python"), venvPath)
const pyls = atom.config.get("ide-python.pyls") || "pyls"

let pyls = atom.config.get("ide-python.pyls") || "pylsp"
// check if it exists
try {
execFileSync(pyls, ["--help"], { stdio: "inherit" })
} catch (e) {
console.error(e)
pyls = "pyls"
}
const childProcess = super.spawn(python, ["-m", pyls], {
cwd: projectPath,
env: pylsEnvironment,
Expand Down Expand Up @@ -83,7 +92,7 @@ class PythonLanguageClient extends AutoLanguageClient {
},
],
description:
"Make sure to install `pyls` 0.19 or newer by running:\n" +
"Make sure to install `pylsp` 0.19 or newer by running:\n" +
"```\n" +
`${python} -m pip install 'python-lsp-server[all]'\n` +
`${python} -m pip install git+https://github.com/tomv564/pyls-mypy.git\n` +
Expand Down
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@
"default": "python",
"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"
},
"pyls-path": {
"title": "Path to pyls executable",
"order": 2,
"type": "string",
"default": "pylsp"
},
"pylsConfigurationSources": {
"order": 2,
"type": "array",
Expand Down

0 comments on commit 01dfc6c

Please sign in to comment.