()
| 327 | @_check_jedi_availability(show_error=False) |
| 328 | @catch_and_print_exceptions |
| 329 | def completions(): |
| 330 | jedi.settings.case_insensitive_completion = \ |
| 331 | bool(int(vim_eval("get(b:, 'jedi_case_insensitive_completion', " |
| 332 | "g:jedi#case_insensitive_completion)"))) |
| 333 | |
| 334 | row, column = vim.current.window.cursor |
| 335 | # Clear call signatures in the buffer so they aren't seen by the completer. |
| 336 | # Call signatures in the command line can stay. |
| 337 | if int(vim_eval("g:jedi#show_call_signatures")) == 1: |
| 338 | clear_call_signatures() |
| 339 | if vim.eval('a:findstart') == '1': |
| 340 | count = 0 |
| 341 | for char in reversed(vim.current.line[:column]): |
| 342 | if not re.match(r'[\w\d]', char): |
| 343 | break |
| 344 | count += 1 |
| 345 | vim.command('return %i' % (column - count)) |
| 346 | else: |
| 347 | base = vim.eval('a:base') |
| 348 | source = '' |
| 349 | for i, line in enumerate(vim.current.buffer): |
| 350 | # enter this path again, otherwise source would be incomplete |
| 351 | if i == row - 1: |
| 352 | source += line[:column] + base + line[column:] |
| 353 | else: |
| 354 | source += line |
| 355 | source += '\n' |
| 356 | # here again hacks, because jedi has a different interface than vim |
| 357 | column += len(base) |
| 358 | try: |
| 359 | script = get_script(source=source) |
| 360 | completions = script.complete(*get_pos(column)) |
| 361 | signatures = script.get_signatures(*get_pos(column)) |
| 362 | |
| 363 | add_info = \ |
| 364 | any(option in vim.eval("&completeopt").split(",") |
| 365 | for option in ("preview", "popup")) |
| 366 | out = [] |
| 367 | for c in completions: |
| 368 | d = dict(word=PythonToVimStr(c.name[:len(base)] + c.complete), |
| 369 | abbr=PythonToVimStr(c.name_with_symbols), |
| 370 | # stuff directly behind the completion |
| 371 | menu=PythonToVimStr(c.description), |
| 372 | icase=1, # case insensitive |
| 373 | dup=1 # allow duplicates (maybe later remove this) |
| 374 | ) |
| 375 | if add_info: |
| 376 | try: |
| 377 | d["info"] = PythonToVimStr(c.docstring()) |
| 378 | except Exception: |
| 379 | print("jedi-vim: error with docstring for %r: %s" % ( |
| 380 | c, traceback.format_exc())) |
| 381 | out.append(d) |
| 382 | |
| 383 | strout = str(out) |
| 384 | except Exception: |
| 385 | # print to stdout, will be in :messages |
| 386 | print(traceback.format_exc()) |
nothing calls this directly
no test coverage detected