forked from VimPlug/jedi-vim
NotFoundError was deprecated in Jedi a while ago
This commit is contained in:
@@ -235,71 +235,68 @@ def goto(mode="goto", no_output=False):
|
|||||||
:rtype: list
|
:rtype: list
|
||||||
"""
|
"""
|
||||||
script = get_script()
|
script = get_script()
|
||||||
try:
|
if mode == "goto":
|
||||||
if mode == "goto":
|
definitions = [x for x in script.goto_definitions()
|
||||||
definitions = [x for x in script.goto_definitions()
|
if not x.in_builtin_module()]
|
||||||
if not x.in_builtin_module()]
|
|
||||||
if not definitions:
|
|
||||||
definitions = script.goto_assignments()
|
|
||||||
elif mode == "related_name":
|
|
||||||
definitions = script.usages()
|
|
||||||
elif mode == "definition":
|
|
||||||
definitions = script.goto_definitions()
|
|
||||||
elif mode == "assignment":
|
|
||||||
definitions = script.goto_assignments()
|
|
||||||
except jedi.NotFoundError:
|
|
||||||
echo_highlight("Cannot follow nothing. Put your cursor on a valid name.")
|
|
||||||
definitions = []
|
|
||||||
else:
|
|
||||||
if no_output:
|
|
||||||
return definitions
|
|
||||||
if not definitions:
|
if not definitions:
|
||||||
echo_highlight("Couldn't find any definitions for this.")
|
definitions = script.goto_assignments()
|
||||||
elif len(definitions) == 1 and mode != "related_name":
|
elif mode == "related_name":
|
||||||
d = list(definitions)[0]
|
definitions = script.usages()
|
||||||
if d.in_builtin_module():
|
elif mode == "definition":
|
||||||
if d.is_keyword:
|
definitions = script.goto_definitions()
|
||||||
echo_highlight("Cannot get the definition of Python keywords.")
|
elif mode == "assignment":
|
||||||
else:
|
definitions = script.goto_assignments()
|
||||||
echo_highlight("Builtin modules cannot be displayed (%s)."
|
|
||||||
% d.desc_with_module)
|
|
||||||
|
if no_output:
|
||||||
|
return definitions
|
||||||
|
if not definitions:
|
||||||
|
echo_highlight("Couldn't find any definitions for this.")
|
||||||
|
elif len(definitions) == 1 and mode != "related_name":
|
||||||
|
d = list(definitions)[0]
|
||||||
|
if d.in_builtin_module():
|
||||||
|
if d.is_keyword:
|
||||||
|
echo_highlight("Cannot get the definition of Python keywords.")
|
||||||
else:
|
else:
|
||||||
using_tagstack = int(vim_eval('g:jedi#use_tag_stack')) == 1
|
echo_highlight("Builtin modules cannot be displayed (%s)."
|
||||||
if d.module_path != vim.current.buffer.name:
|
% d.desc_with_module)
|
||||||
result = new_buffer(d.module_path,
|
|
||||||
using_tagstack=using_tagstack)
|
|
||||||
if not result:
|
|
||||||
return []
|
|
||||||
if d.module_path and os.path.exists(d.module_path) and using_tagstack:
|
|
||||||
tagname = d.name
|
|
||||||
with tempfile('{0}\t{1}\t{2}'.format(tagname, d.module_path,
|
|
||||||
'call cursor({0}, {1})'.format(d.line, d.column + 1))) as f:
|
|
||||||
old_tags = vim.eval('&tags')
|
|
||||||
old_wildignore = vim.eval('&wildignore')
|
|
||||||
try:
|
|
||||||
# Clear wildignore to ensure tag file isn't ignored
|
|
||||||
vim.command('set wildignore=')
|
|
||||||
vim.command('let &tags = %s' %
|
|
||||||
repr(PythonToVimStr(f.name)))
|
|
||||||
vim.command('tjump %s' % tagname)
|
|
||||||
finally:
|
|
||||||
vim.command('let &tags = %s' %
|
|
||||||
repr(PythonToVimStr(old_tags)))
|
|
||||||
vim.command('let &wildignore = %s' %
|
|
||||||
repr(PythonToVimStr(old_wildignore)))
|
|
||||||
vim.current.window.cursor = d.line, d.column
|
|
||||||
else:
|
else:
|
||||||
# multiple solutions
|
using_tagstack = int(vim_eval('g:jedi#use_tag_stack')) == 1
|
||||||
lst = []
|
if d.module_path != vim.current.buffer.name:
|
||||||
for d in definitions:
|
result = new_buffer(d.module_path,
|
||||||
if d.in_builtin_module():
|
using_tagstack=using_tagstack)
|
||||||
lst.append(dict(text=PythonToVimStr('Builtin ' + d.description)))
|
if not result:
|
||||||
else:
|
return []
|
||||||
lst.append(dict(filename=PythonToVimStr(d.module_path),
|
if d.module_path and os.path.exists(d.module_path) and using_tagstack:
|
||||||
lnum=d.line, col=d.column + 1,
|
tagname = d.name
|
||||||
text=PythonToVimStr(d.description)))
|
with tempfile('{0}\t{1}\t{2}'.format(tagname, d.module_path,
|
||||||
vim_eval('setqflist(%s)' % repr(lst))
|
'call cursor({0}, {1})'.format(d.line, d.column + 1))) as f:
|
||||||
vim_eval('jedi#add_goto_window(' + str(len(lst)) + ')')
|
old_tags = vim.eval('&tags')
|
||||||
|
old_wildignore = vim.eval('&wildignore')
|
||||||
|
try:
|
||||||
|
# Clear wildignore to ensure tag file isn't ignored
|
||||||
|
vim.command('set wildignore=')
|
||||||
|
vim.command('let &tags = %s' %
|
||||||
|
repr(PythonToVimStr(f.name)))
|
||||||
|
vim.command('tjump %s' % tagname)
|
||||||
|
finally:
|
||||||
|
vim.command('let &tags = %s' %
|
||||||
|
repr(PythonToVimStr(old_tags)))
|
||||||
|
vim.command('let &wildignore = %s' %
|
||||||
|
repr(PythonToVimStr(old_wildignore)))
|
||||||
|
vim.current.window.cursor = d.line, d.column
|
||||||
|
else:
|
||||||
|
# multiple solutions
|
||||||
|
lst = []
|
||||||
|
for d in definitions:
|
||||||
|
if d.in_builtin_module():
|
||||||
|
lst.append(dict(text=PythonToVimStr('Builtin ' + d.description)))
|
||||||
|
else:
|
||||||
|
lst.append(dict(filename=PythonToVimStr(d.module_path),
|
||||||
|
lnum=d.line, col=d.column + 1,
|
||||||
|
text=PythonToVimStr(d.description)))
|
||||||
|
vim_eval('setqflist(%s)' % repr(lst))
|
||||||
|
vim_eval('jedi#add_goto_window(' + str(len(lst)) + ')')
|
||||||
return definitions
|
return definitions
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user