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 11const cp = require ( "child_process" ) ;
22const { shell } = require ( "electron" ) ;
33const { AutoLanguageClient } = require ( "atom-languageclient" ) ;
4+ const { Directory } = require ( "atom" ) ;
45
56// Ref: https://github.com/nteract/hydrogen/blob/master/lib/autocomplete-provider.js#L33
67// adapted from http://stackoverflow.com/q/5474008
@@ -30,8 +31,19 @@ class PythonLanguageClient extends AutoLanguageClient {
3031 async startServerProcess ( projectPath ) {
3132 await new Promise ( resolve => atom . whenShellEnvironmentLoaded ( resolve ) ) ;
3233
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+
3344 const childProcess = cp . spawn ( atom . config . get ( "ide-python.pylsPath" ) , {
34- cwd : projectPath
45+ cwd : projectPath ,
46+ env : pylsEnvironment
3547 } ) ;
3648 childProcess . on ( "error" , err =>
3749 atom . notifications . addError (
You can’t perform that action at this time.
0 commit comments