File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change 1
1
const cp = require ( "child_process" ) ;
2
2
const { shell } = require ( "electron" ) ;
3
3
const { AutoLanguageClient } = require ( "atom-languageclient" ) ;
4
+ const { Directory } = require ( "atom" ) ;
4
5
5
6
// Ref: https://github.com/nteract/hydrogen/blob/master/lib/autocomplete-provider.js#L33
6
7
// adapted from http://stackoverflow.com/q/5474008
@@ -30,8 +31,19 @@ class PythonLanguageClient extends AutoLanguageClient {
30
31
async startServerProcess ( projectPath ) {
31
32
await new Promise ( resolve => atom . whenShellEnvironmentLoaded ( resolve ) ) ;
32
33
34
+ var venvPromise = new Directory ( projectPath ) . getSubdirectory ( 'bin' )
35
+ . getFile ( 'python' )
36
+ . exists ( ) ;
37
+
38
+ var pylsEnvironment = Object . assign ( { } , process . env ) ;
39
+
40
+ if ( await venvPromise ) {
41
+ pylsEnvironment [ 'VIRTUAL_ENV' ] = projectPath ;
42
+ }
43
+
33
44
const childProcess = cp . spawn ( atom . config . get ( "ide-python.pylsPath" ) , {
34
- cwd : projectPath
45
+ cwd : projectPath ,
46
+ env : pylsEnvironment
35
47
} ) ;
36
48
childProcess . on ( "error" , err =>
37
49
atom . notifications . addError (
You can’t perform that action at this time.
0 commit comments