|
1 |
| -const cp = require("child_process") |
2 | 1 | const { shell } = require("electron")
|
3 | 2 | const { AutoLanguageClient } = require("atom-languageclient")
|
4 | 3 | const { detectVirtualEnv, detectPipEnv, replacePipEnvPathVar, sanitizeConfig } = require("./utils")
|
@@ -50,45 +49,46 @@ class PythonLanguageClient extends AutoLanguageClient {
|
50 | 49 | pylsEnvironment["VIRTUAL_ENV"] = venvPath
|
51 | 50 | }
|
52 | 51 | const python = replacePipEnvPathVar(atom.config.get("ide-python.python"), venvPath)
|
53 |
| - const childProcess = cp.spawn(python, ["-m", "pyls"], { |
| 52 | + const childProcess = super.spawn(python, ["-m", "pyls"], { |
54 | 53 | cwd: projectPath,
|
55 | 54 | env: pylsEnvironment,
|
56 | 55 | })
|
57 |
| - childProcess.on("error", (err) => { |
58 |
| - const description = |
59 |
| - err.code == "ENOENT" |
60 |
| - ? `No Python interpreter found at \`${python}\`.` |
61 |
| - : `Could not spawn the Python interpreter \`${python}\`.` |
62 |
| - atom.notifications.addError("`ide-python` could not launch your Python runtime.", { |
63 |
| - dismissable: true, |
64 |
| - description: `${description}<p>If you have Python installed please set "Python Executable" setting correctly. If you do not please install Python.</p>`, |
65 |
| - }) |
66 |
| - }) |
| 56 | + return childProcess |
| 57 | + } |
67 | 58 |
|
68 |
| - childProcess.on("close", (code, signal) => { |
69 |
| - if (code !== 0 && signal == null) { |
70 |
| - atom.notifications.addError("Unable to start the Python language server.", { |
71 |
| - dismissable: true, |
72 |
| - buttons: [ |
73 |
| - { |
74 |
| - text: "Install Instructions", |
75 |
| - onDidClick: () => atom.workspace.open("atom://config/packages/ide-python"), |
76 |
| - }, |
77 |
| - { |
78 |
| - text: "Download Python", |
79 |
| - onDidClick: () => shell.openExternal("https://www.python.org/downloads/"), |
80 |
| - }, |
81 |
| - ], |
82 |
| - description: |
83 |
| - "Make sure to install `pyls` 0.19 or newer by running:\n" + |
84 |
| - "```\n" + |
85 |
| - `${python} -m pip install 'python-language-server[all]'\n` + |
86 |
| - `${python} -m pip install git+https://github.com/tomv564/pyls-mypy.git\n` + |
87 |
| - "```", |
88 |
| - }) |
89 |
| - } |
| 59 | + onSpawnError(err) { |
| 60 | + const description = |
| 61 | + err.code == "ENOENT" |
| 62 | + ? `No Python interpreter found at \`${python}\`.` |
| 63 | + : `Could not spawn the Python interpreter \`${python}\`.` |
| 64 | + atom.notifications.addError("`ide-python` could not launch your Python runtime.", { |
| 65 | + dismissable: true, |
| 66 | + description: `${description}<p>If you have Python installed please set "Python Executable" setting correctly. If you do not please install Python.</p>`, |
90 | 67 | })
|
91 |
| - return childProcess |
| 68 | + } |
| 69 | + |
| 70 | + onSpawnClose(code, signal) { |
| 71 | + if (code !== 0 && signal == null) { |
| 72 | + atom.notifications.addError("Unable to start the Python language server.", { |
| 73 | + dismissable: true, |
| 74 | + buttons: [ |
| 75 | + { |
| 76 | + text: "Install Instructions", |
| 77 | + onDidClick: () => atom.workspace.open("atom://config/packages/ide-python"), |
| 78 | + }, |
| 79 | + { |
| 80 | + text: "Download Python", |
| 81 | + onDidClick: () => shell.openExternal("https://www.python.org/downloads/"), |
| 82 | + }, |
| 83 | + ], |
| 84 | + description: |
| 85 | + "Make sure to install `pyls` 0.19 or newer by running:\n" + |
| 86 | + "```\n" + |
| 87 | + `${python} -m pip install 'python-language-server[all]'\n` + |
| 88 | + `${python} -m pip install git+https://github.com/tomv564/pyls-mypy.git\n` + |
| 89 | + "```", |
| 90 | + }) |
| 91 | + } |
92 | 92 | }
|
93 | 93 |
|
94 | 94 | async getSuggestions(request) {
|
|
0 commit comments