Skip to content

Instantly share code, notes, and snippets.

@heavenshell
Last active December 17, 2015 22:29
Show Gist options
  • Save heavenshell/5682839 to your computer and use it in GitHub Desktop.
Save heavenshell/5682839 to your computer and use it in GitHub Desktop.
diff --git a/plugin/jedi.vim b/plugin/jedi.vim
index 9e0b013..aba7e18 100644
--- a/plugin/jedi.vim
+++ b/plugin/jedi.vim
@@ -68,7 +68,7 @@ if 1:
text = 'import %s' % args.pop()
scr = jedi.Script(text, 1, len(text), '')
try:
- path = scr.goto()[0].module_path
+ path = scr.goto_assignments()[0].module_path
except IndexError:
path = None
if path and osp.isfile(path):
@@ -92,7 +92,7 @@ if 1:
else:
text = 'import %s' % argl
script=jedi.Script(text, 1, len(text), '')
- comps = [ '%s%s' % (argl, c.complete) for c in script.complete()]
+ comps = ['%s%s' % (argl, c.complete) for c in script.completions()]
vim.command("let comps = '%s'" % '\n'.join(comps))
return comps
diff --git a/plugin/jedi_vim.py b/plugin/jedi_vim.py
index a355cdb..737f579 100644
--- a/plugin/jedi_vim.py
+++ b/plugin/jedi_vim.py
@@ -71,13 +71,14 @@ def complete():
column += len(base)
try:
script = get_script(source=source, column=column)
- completions = script.complete()
- call_def = script.get_in_function_call()
+ completions = script.completions()
+ sig = script.call_signatures()
+ call_def =sig[0] if sig else None
out = []
for c in completions:
- d = dict(word=PythonToVimStr(c.word[:len(base)] + c.complete),
- abbr=PythonToVimStr(c.word),
+ d = dict(word=PythonToVimStr(c.name[:len(base)] + c.complete),
+ abbr=PythonToVimStr(c.name),
# stuff directly behind the completion
menu=PythonToVimStr(c.description),
info=PythonToVimStr(c.doc), # docstr
@@ -104,11 +105,11 @@ def goto(is_definition=False, is_related_name=False, no_output=False):
script = get_script()
try:
if is_related_name:
- definitions = script.related_names()
+ definitions = script.usages()
elif is_definition:
- definitions = script.get_definition()
+ definitions = script.goto_definitions()
else:
- definitions = script.goto()
+ definitions = script.goto_assignments()
except jedi.NotFoundError:
echo_highlight(
"Cannot follow nothing. Put your cursor on a valid name.")
@@ -138,7 +139,7 @@ def goto(is_definition=False, is_related_name=False, no_output=False):
if d.module_path != vim.current.buffer.name:
vim.eval('jedi#new_buffer(%s)' % \
repr(PythonToVimStr(d.module_path)))
- vim.current.window.cursor = d.line_nr, d.column
+ vim.current.window.cursor = d.line, d.column
vim.command('normal! zt') # cursor at top of screen
else:
# multiple solutions
@@ -149,7 +150,7 @@ def goto(is_definition=False, is_related_name=False, no_output=False):
PythonToVimStr('Builtin ' + d.description)))
else:
lst.append(dict(filename=PythonToVimStr(d.module_path),
- lnum=d.line_nr, col=d.column + 1,
+ lnum=d.line, col=d.column + 1,
text=PythonToVimStr(d.description)))
vim.eval('setqflist(%s)' % repr(lst))
vim.eval('jedi#add_goto_window()')
@@ -159,7 +160,7 @@ def goto(is_definition=False, is_related_name=False, no_output=False):
def show_pydoc():
script = get_script()
try:
- definitions = script.get_definition()
+ definitions = script.goto_definitions()
except jedi.NotFoundError:
definitions = []
except Exception:
@@ -199,7 +200,8 @@ def show_func_def(call_def=None, completion_lines=0):
return
try:
if call_def == None:
- call_def = get_script().get_in_function_call()
+ sig = get_script().call_signatures()
+ call_def = sig[0] if sig else None
clear_func_def()
if call_def is None:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment