mirror of
https://github.com/davidhalter/jedi-vim.git
synced 2025-12-06 10:54:22 +08:00
Merge branch 'dev' of github.com:davidhalter/jedi-vim into dev
This commit is contained in:
@@ -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))
|
||||
EOF
|
||||
return comps
|
||||
|
||||
@@ -30,7 +30,10 @@ class PythonToVimStr(unicode):
|
||||
# support is pretty bad. don't ask how I came up with this... It just
|
||||
# works...
|
||||
# It seems to be related to that bug: http://bugs.python.org/issue5876
|
||||
s = self.encode('UTF-8')
|
||||
if unicode is str:
|
||||
s = self
|
||||
else:
|
||||
s = self.encode('UTF-8')
|
||||
return '"%s"' % s.replace('\\', '\\\\').replace('"', r'\"')
|
||||
|
||||
|
||||
@@ -71,13 +74,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 +108,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.")
|
||||
@@ -159,7 +163,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 +203,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:
|
||||
@@ -232,7 +237,9 @@ def show_func_def(call_def=None, completion_lines=0):
|
||||
|
||||
# Need to decode it with utf8, because vim returns always a python 2
|
||||
# string even if it is unicode.
|
||||
e = vim.eval('g:jedi#function_definition_escape').decode('UTF-8')
|
||||
e = vim.eval('g:jedi#function_definition_escape')
|
||||
if hasattr(e, 'decode'):
|
||||
e = e.decode('UTF-8')
|
||||
# replace line before with cursor
|
||||
regex = "xjedi=%sx%sxjedix".replace('x', e)
|
||||
|
||||
@@ -317,7 +324,7 @@ def tabnew(path):
|
||||
buf_nr = int(buf_nr) - 1
|
||||
try:
|
||||
buf_path = vim.buffers[buf_nr].name
|
||||
except IndexError:
|
||||
except LookupError:
|
||||
# Just do good old asking for forgiveness.
|
||||
# don't know why this happens :-)
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user