@@ -33,6 +33,7 @@ class JediCompletion(object): |
33 | 33 |
|
34 | 34 | def __init__(self): |
35 | 35 | self.default_sys_path = sys.path |
| 36 | + self.environment = jedi.api.environment.Environment(sys.prefix, sys.executable) |
36 | 37 | self._input = io.open(sys.stdin.fileno(), encoding='utf-8') |
37 | 38 | if (os.path.sep == '/') and (platform.uname()[2].find('Microsoft') > -1): |
38 | 39 | # WSL; does not support UNC paths |
@@ -150,7 +151,7 @@ def _get_call_signatures_with_args(self, script): |
150 | 151 | except Exception: |
151 | 152 | sig["docstring"] = '' |
152 | 153 | sig["raw_docstring"] = '' |
153 | | - |
| 154 | + |
154 | 155 | sig["name"] = signature.name |
155 | 156 | sig["paramindex"] = signature.index |
156 | 157 | sig["bracketstart"].append(signature.index) |
@@ -199,7 +200,7 @@ def _serialize_completions(self, script, identifier=None, prefix=''): |
199 | 200 | } |
200 | 201 | _completion['description'] = '' |
201 | 202 | _completion['raw_docstring'] = '' |
202 | | - |
| 203 | + |
203 | 204 | # we pass 'text' here only for fuzzy matcher |
204 | 205 | if value: |
205 | 206 | _completion['snippet'] = '%s=${1:%s}$0' % (name, value) |
@@ -223,15 +224,15 @@ def _serialize_completions(self, script, identifier=None, prefix=''): |
223 | 224 | 'type': self._get_definition_type(completion), |
224 | 225 | 'raw_type': completion.type, |
225 | 226 | 'rightLabel': self._additional_info(completion) |
226 | | - } |
| 227 | + } |
227 | 228 | except Exception: |
228 | 229 | continue |
229 | 230 |
|
230 | 231 | for c in _completions: |
231 | 232 | if c['text'] == _completion['text']: |
232 | 233 | c['type'] = _completion['type'] |
233 | 234 | c['raw_type'] = _completion['raw_type'] |
234 | | - |
| 235 | + |
235 | 236 | if any([c['text'].split('=')[0] == _completion['text'] |
236 | 237 | for c in _completions]): |
237 | 238 | # ignore function arguments we already have |
@@ -361,7 +362,7 @@ def _get_definitionsx(self, definitions, identifier=None, ignoreNoModulePath=Fal |
361 | 362 | definition = self._top_definition(definition) |
362 | 363 | definitionRange = { |
363 | 364 | 'start_line': 0, |
364 | | - 'start_column': 0, |
| 365 | + 'start_column': 0, |
365 | 366 | 'end_line': 0, |
366 | 367 | 'end_column': 0 |
367 | 368 | } |
@@ -377,7 +378,7 @@ def _get_definitionsx(self, definitions, identifier=None, ignoreNoModulePath=Fal |
377 | 378 | container = parent.name if parent.type != 'module' else '' |
378 | 379 | except Exception: |
379 | 380 | container = '' |
380 | | - |
| 381 | + |
381 | 382 | try: |
382 | 383 | docstring = definition.docstring() |
383 | 384 | rawdocstring = definition.docstring(raw=True) |
@@ -424,7 +425,7 @@ def _serialize_definitions(self, definitions, identifier=None): |
424 | 425 | container = parent.name if parent.type != 'module' else '' |
425 | 426 | except Exception: |
426 | 427 | container = '' |
427 | | - |
| 428 | + |
428 | 429 | try: |
429 | 430 | docstring = definition.docstring() |
430 | 431 | rawdocstring = definition.docstring(raw=True) |
@@ -474,7 +475,7 @@ def _serialize_tooltip(self, definitions, identifier=None): |
474 | 475 | 'type': self._get_definition_type(definition), |
475 | 476 | 'text': definition.name, |
476 | 477 | 'description': description, |
477 | | - 'docstring': description, |
| 478 | + 'docstring': description, |
478 | 479 | 'signature': signature |
479 | 480 | } |
480 | 481 | _definitions.append(_definition) |
@@ -566,8 +567,8 @@ def _process_request(self, request): |
566 | 567 | script = jedi.Script( |
567 | 568 | source=request.get('source', None), line=request['line'] + 1, |
568 | 569 | column=request['column'], path=request.get('path', ''), |
569 | | - sys_path=sys.path) |
570 | | - |
| 570 | + sys_path=sys.path, environment=self.environment) |
| 571 | + |
571 | 572 | if lookup == 'definitions': |
572 | 573 | defs = [] |
573 | 574 | try: |
@@ -625,7 +626,7 @@ def watch(self): |
625 | 626 | try: |
626 | 627 | rq = self._input.readline() |
627 | 628 | if len(rq) == 0: |
628 | | - # Reached EOF - indication our parent process is gone. |
| 629 | + # Reached EOF - indication our parent process is gone. |
629 | 630 | sys.stderr.write('Received EOF from the standard input,exiting' + '\n') |
630 | 631 | sys.stderr.flush() |
631 | 632 | return |
|