@@ -33,6 +33,7 @@ class JediCompletion(object):
3333
3434 def __init__ (self ):
3535 self .default_sys_path = sys .path
36+ self .environment = jedi .api .environment .Environment (sys .prefix , sys .executable )
3637 self ._input = io .open (sys .stdin .fileno (), encoding = 'utf-8' )
3738 if (os .path .sep == '/' ) and (platform .uname ()[2 ].find ('Microsoft' ) > - 1 ):
3839 # WSL; does not support UNC paths
@@ -150,7 +151,7 @@ def _get_call_signatures_with_args(self, script):
150151 except Exception :
151152 sig ["docstring" ] = ''
152153 sig ["raw_docstring" ] = ''
153-
154+
154155 sig ["name" ] = signature .name
155156 sig ["paramindex" ] = signature .index
156157 sig ["bracketstart" ].append (signature .index )
@@ -199,7 +200,7 @@ def _serialize_completions(self, script, identifier=None, prefix=''):
199200 }
200201 _completion ['description' ] = ''
201202 _completion ['raw_docstring' ] = ''
202-
203+
203204 # we pass 'text' here only for fuzzy matcher
204205 if value :
205206 _completion ['snippet' ] = '%s=${1:%s}$0' % (name , value )
@@ -223,15 +224,15 @@ def _serialize_completions(self, script, identifier=None, prefix=''):
223224 'type' : self ._get_definition_type (completion ),
224225 'raw_type' : completion .type ,
225226 'rightLabel' : self ._additional_info (completion )
226- }
227+ }
227228 except Exception :
228229 continue
229230
230231 for c in _completions :
231232 if c ['text' ] == _completion ['text' ]:
232233 c ['type' ] = _completion ['type' ]
233234 c ['raw_type' ] = _completion ['raw_type' ]
234-
235+
235236 if any ([c ['text' ].split ('=' )[0 ] == _completion ['text' ]
236237 for c in _completions ]):
237238 # ignore function arguments we already have
@@ -361,7 +362,7 @@ def _get_definitionsx(self, definitions, identifier=None, ignoreNoModulePath=Fal
361362 definition = self ._top_definition (definition )
362363 definitionRange = {
363364 'start_line' : 0 ,
364- 'start_column' : 0 ,
365+ 'start_column' : 0 ,
365366 'end_line' : 0 ,
366367 'end_column' : 0
367368 }
@@ -377,7 +378,7 @@ def _get_definitionsx(self, definitions, identifier=None, ignoreNoModulePath=Fal
377378 container = parent .name if parent .type != 'module' else ''
378379 except Exception :
379380 container = ''
380-
381+
381382 try :
382383 docstring = definition .docstring ()
383384 rawdocstring = definition .docstring (raw = True )
@@ -424,7 +425,7 @@ def _serialize_definitions(self, definitions, identifier=None):
424425 container = parent .name if parent .type != 'module' else ''
425426 except Exception :
426427 container = ''
427-
428+
428429 try :
429430 docstring = definition .docstring ()
430431 rawdocstring = definition .docstring (raw = True )
@@ -474,7 +475,7 @@ def _serialize_tooltip(self, definitions, identifier=None):
474475 'type' : self ._get_definition_type (definition ),
475476 'text' : definition .name ,
476477 'description' : description ,
477- 'docstring' : description ,
478+ 'docstring' : description ,
478479 'signature' : signature
479480 }
480481 _definitions .append (_definition )
@@ -566,8 +567,8 @@ def _process_request(self, request):
566567 script = jedi .Script (
567568 source = request .get ('source' , None ), line = request ['line' ] + 1 ,
568569 column = request ['column' ], path = request .get ('path' , '' ),
569- sys_path = sys .path )
570-
570+ sys_path = sys .path , environment = self . environment )
571+
571572 if lookup == 'definitions' :
572573 defs = []
573574 try :
@@ -625,7 +626,7 @@ def watch(self):
625626 try :
626627 rq = self ._input .readline ()
627628 if len (rq ) == 0 :
628- # Reached EOF - indication our parent process is gone.
629+ # Reached EOF - indication our parent process is gone.
629630 sys .stderr .write ('Received EOF from the standard input,exiting' + '\n ' )
630631 sys .stderr .flush ()
631632 return
0 commit comments