mirror of
https://github.com/davidhalter/jedi-vim.git
synced 2025-12-10 12:31:52 +08:00
Merge pull request #138 from heavenshell/fix_deprecation_warning
Fix not to use deprecated method
This commit is contained in:
@@ -68,7 +68,7 @@ if 1:
|
|||||||
text = 'import %s' % args.pop()
|
text = 'import %s' % args.pop()
|
||||||
scr = jedi.Script(text, 1, len(text), '')
|
scr = jedi.Script(text, 1, len(text), '')
|
||||||
try:
|
try:
|
||||||
path = scr.goto()[0].module_path
|
path = scr.goto_assignments()[0].module_path
|
||||||
except IndexError:
|
except IndexError:
|
||||||
path = None
|
path = None
|
||||||
if path and osp.isfile(path):
|
if path and osp.isfile(path):
|
||||||
@@ -92,7 +92,7 @@ if 1:
|
|||||||
else:
|
else:
|
||||||
text = 'import %s' % argl
|
text = 'import %s' % argl
|
||||||
script=jedi.Script(text, 1, len(text), '')
|
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))
|
vim.command("let comps = '%s'" % '\n'.join(comps))
|
||||||
EOF
|
EOF
|
||||||
return comps
|
return comps
|
||||||
|
|||||||
@@ -74,13 +74,14 @@ def complete():
|
|||||||
column += len(base)
|
column += len(base)
|
||||||
try:
|
try:
|
||||||
script = get_script(source=source, column=column)
|
script = get_script(source=source, column=column)
|
||||||
completions = script.complete()
|
completions = script.completions()
|
||||||
call_def = script.get_in_function_call()
|
sig = script.call_signatures()
|
||||||
|
call_def =sig[0] if sig else None
|
||||||
|
|
||||||
out = []
|
out = []
|
||||||
for c in completions:
|
for c in completions:
|
||||||
d = dict(word=PythonToVimStr(c.word[:len(base)] + c.complete),
|
d = dict(word=PythonToVimStr(c.name[:len(base)] + c.complete),
|
||||||
abbr=PythonToVimStr(c.word),
|
abbr=PythonToVimStr(c.name),
|
||||||
# stuff directly behind the completion
|
# stuff directly behind the completion
|
||||||
menu=PythonToVimStr(c.description),
|
menu=PythonToVimStr(c.description),
|
||||||
info=PythonToVimStr(c.doc), # docstr
|
info=PythonToVimStr(c.doc), # docstr
|
||||||
@@ -107,11 +108,11 @@ def goto(is_definition=False, is_related_name=False, no_output=False):
|
|||||||
script = get_script()
|
script = get_script()
|
||||||
try:
|
try:
|
||||||
if is_related_name:
|
if is_related_name:
|
||||||
definitions = script.related_names()
|
definitions = script.usages()
|
||||||
elif is_definition:
|
elif is_definition:
|
||||||
definitions = script.get_definition()
|
definitions = script.goto_definitions()
|
||||||
else:
|
else:
|
||||||
definitions = script.goto()
|
definitions = script.goto_assignments()
|
||||||
except jedi.NotFoundError:
|
except jedi.NotFoundError:
|
||||||
echo_highlight(
|
echo_highlight(
|
||||||
"Cannot follow nothing. Put your cursor on a valid name.")
|
"Cannot follow nothing. Put your cursor on a valid name.")
|
||||||
@@ -141,7 +142,7 @@ def goto(is_definition=False, is_related_name=False, no_output=False):
|
|||||||
if d.module_path != vim.current.buffer.name:
|
if d.module_path != vim.current.buffer.name:
|
||||||
vim.eval('jedi#new_buffer(%s)' % \
|
vim.eval('jedi#new_buffer(%s)' % \
|
||||||
repr(PythonToVimStr(d.module_path)))
|
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
|
vim.command('normal! zt') # cursor at top of screen
|
||||||
else:
|
else:
|
||||||
# multiple solutions
|
# multiple solutions
|
||||||
@@ -152,7 +153,7 @@ def goto(is_definition=False, is_related_name=False, no_output=False):
|
|||||||
PythonToVimStr('Builtin ' + d.description)))
|
PythonToVimStr('Builtin ' + d.description)))
|
||||||
else:
|
else:
|
||||||
lst.append(dict(filename=PythonToVimStr(d.module_path),
|
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)))
|
text=PythonToVimStr(d.description)))
|
||||||
vim.eval('setqflist(%s)' % repr(lst))
|
vim.eval('setqflist(%s)' % repr(lst))
|
||||||
vim.eval('jedi#add_goto_window()')
|
vim.eval('jedi#add_goto_window()')
|
||||||
@@ -162,7 +163,7 @@ def goto(is_definition=False, is_related_name=False, no_output=False):
|
|||||||
def show_pydoc():
|
def show_pydoc():
|
||||||
script = get_script()
|
script = get_script()
|
||||||
try:
|
try:
|
||||||
definitions = script.get_definition()
|
definitions = script.goto_definitions()
|
||||||
except jedi.NotFoundError:
|
except jedi.NotFoundError:
|
||||||
definitions = []
|
definitions = []
|
||||||
except Exception:
|
except Exception:
|
||||||
@@ -202,7 +203,8 @@ def show_func_def(call_def=None, completion_lines=0):
|
|||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
if call_def == None:
|
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()
|
clear_func_def()
|
||||||
|
|
||||||
if call_def is None:
|
if call_def is None:
|
||||||
|
|||||||
Reference in New Issue
Block a user