Skip to content
Closed
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
13 changes: 9 additions & 4 deletions lib/main.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
const cp = require("child_process");
const shellEnv = require("shell-env");
const { shell } = require("electron");
const { AutoLanguageClient } = require("atom-languageclient");

// Ref: https://github.com/nteract/hydrogen/blob/master/lib/autocomplete-provider.js#L33
// adapted from http://stackoverflow.com/q/5474008
const PYTHON_REGEX = /(([^\d\W]|[\u00A0-\uFFFF])[\w.\u00A0-\uFFFF]*)|\.$/;

function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}

class PythonLanguageClient extends AutoLanguageClient {
getGrammarScopes() {
return ["source.python"];
Expand All @@ -29,10 +32,12 @@ class PythonLanguageClient extends AutoLanguageClient {
}

async startServerProcess(projectPath) {
const env = await shellEnv();
while (!atom.shellEnvironmentLoaded) {
await sleep(100);
}
const childProcess = cp.spawn(atom.config.get("ide-python.pylsPath"), {
cwd: projectPath,
env: env
env: atom.getLoadSettings().env
});
childProcess.on("error", err =>
atom.notifications.addError(
Expand All @@ -56,7 +61,7 @@ class PythonLanguageClient extends AutoLanguageClient {
}
)
);
return childProcess;
return childProcess;
}

async getSuggestions(request) {
Expand Down