From d56bf264e778441054982499d392c58785f56b13 Mon Sep 17 00:00:00 2001 From: Matthew Moses Date: Sun, 19 May 2013 03:18:23 -0400 Subject: [PATCH 01/10] Fix some errors when vim is compiled with +python3. When vim is compiled with `-python` and `+python3`, jedi-vim generates errors because of two points in the code which are not compatible with Python 3 (because of the `str`/`unicode` vs. `bytes`/`str` thing). --- plugin/jedi_vim.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/plugin/jedi_vim.py b/plugin/jedi_vim.py index a355cdb..6a6d683 100644 --- a/plugin/jedi_vim.py +++ b/plugin/jedi_vim.py @@ -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'\"') @@ -232,7 +235,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) From cf3182e549c8cab2f317b00639ebe3d3a35969cd Mon Sep 17 00:00:00 2001 From: heavenshell Date: Sat, 1 Jun 2013 00:27:14 +0900 Subject: [PATCH 02/10] Fix complete() deprecation. --- plugin/jedi.vim | 2 +- plugin/jedi_vim.py | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/plugin/jedi.vim b/plugin/jedi.vim index 9e0b013..640b2f3 100644 --- a/plugin/jedi.vim +++ b/plugin/jedi.vim @@ -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 diff --git a/plugin/jedi_vim.py b/plugin/jedi_vim.py index a355cdb..3215771 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 From efb1997218cfd64df147e4dcc7756c5b4c650628 Mon Sep 17 00:00:00 2001 From: heavenshell Date: Sat, 1 Jun 2013 00:37:15 +0900 Subject: [PATCH 03/10] Fix show_pydoc() get_definition() deprecation. --- plugin/jedi_vim.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/jedi_vim.py b/plugin/jedi_vim.py index 3215771..b25f52b 100644 --- a/plugin/jedi_vim.py +++ b/plugin/jedi_vim.py @@ -160,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: From e4a2a0f30e780b6b7e87c8563faa6bc72f2b31bd Mon Sep 17 00:00:00 2001 From: heavenshell Date: Sat, 1 Jun 2013 00:41:04 +0900 Subject: [PATCH 04/10] Fix get_definition() deprecation. --- plugin/jedi_vim.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin/jedi_vim.py b/plugin/jedi_vim.py index b25f52b..30c2a37 100644 --- a/plugin/jedi_vim.py +++ b/plugin/jedi_vim.py @@ -107,7 +107,7 @@ def goto(is_definition=False, is_related_name=False, no_output=False): if is_related_name: definitions = script.related_names() elif is_definition: - definitions = script.get_definition() + definitions = script.goto_definitions() else: definitions = script.goto() except jedi.NotFoundError: @@ -150,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()') From 355203cab068a3a48041a229aa31c5dd73be7f3a Mon Sep 17 00:00:00 2001 From: heavenshell Date: Sat, 1 Jun 2013 00:47:11 +0900 Subject: [PATCH 05/10] Fix goto() deprecation. --- plugin/jedi_vim.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin/jedi_vim.py b/plugin/jedi_vim.py index 30c2a37..18e5b35 100644 --- a/plugin/jedi_vim.py +++ b/plugin/jedi_vim.py @@ -109,7 +109,7 @@ def goto(is_definition=False, is_related_name=False, no_output=False): elif is_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.") @@ -139,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 From 6f107578ee6a7f9c393a349910a8fa1deeaf133e Mon Sep 17 00:00:00 2001 From: heavenshell Date: Sat, 1 Jun 2013 00:50:02 +0900 Subject: [PATCH 06/10] Fix related_names() deprecation. --- plugin/jedi_vim.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/jedi_vim.py b/plugin/jedi_vim.py index 18e5b35..a9c2fca 100644 --- a/plugin/jedi_vim.py +++ b/plugin/jedi_vim.py @@ -105,7 +105,7 @@ 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.goto_definitions() else: From a8422d368283d147b4e43b194d097f225867ce4f Mon Sep 17 00:00:00 2001 From: heavenshell Date: Sat, 1 Jun 2013 00:56:04 +0900 Subject: [PATCH 07/10] Fix get_in_function_call() deprecation. --- plugin/jedi_vim.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugin/jedi_vim.py b/plugin/jedi_vim.py index a9c2fca..5f88a3e 100644 --- a/plugin/jedi_vim.py +++ b/plugin/jedi_vim.py @@ -200,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: From 9c3e9dbe03a7174ba43780a48608ace74b735332 Mon Sep 17 00:00:00 2001 From: heavenshell Date: Sat, 1 Jun 2013 00:59:49 +0900 Subject: [PATCH 08/10] Fix goto() deprecation. --- plugin/jedi.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/jedi.vim b/plugin/jedi.vim index 640b2f3..ac36f14 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): From 108cfbdd5d0e16945e5a7d6c8961123a7f32d0e3 Mon Sep 17 00:00:00 2001 From: heavenshell Date: Mon, 3 Jun 2013 20:55:38 +0900 Subject: [PATCH 09/10] Add whitespace after . --- plugin/jedi_vim.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/jedi_vim.py b/plugin/jedi_vim.py index 8422e0f..ec775e3 100644 --- a/plugin/jedi_vim.py +++ b/plugin/jedi_vim.py @@ -76,7 +76,7 @@ def complete(): script = get_script(source=source, column=column) completions = script.completions() sig = script.call_signatures() - call_def =sig[0] if sig else None + call_def = sig[0] if sig else None out = [] for c in completions: From ca50a02a86a9cb92e135db9d0f8c5427d9bc25a3 Mon Sep 17 00:00:00 2001 From: Guillaume Poulin Date: Wed, 3 Jul 2013 02:57:55 +0800 Subject: [PATCH 10/10] Modify IndexError to LookupError in tabnew --- plugin/jedi_vim.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/jedi_vim.py b/plugin/jedi_vim.py index ec775e3..8d41a71 100644 --- a/plugin/jedi_vim.py +++ b/plugin/jedi_vim.py @@ -324,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