From 3ac2b89fcf3e8c582a1bcf76398a6ebb0c02218b Mon Sep 17 00:00:00 2001 From: David Halter Date: Sat, 15 Sep 2012 04:14:47 +0200 Subject: [PATCH] showing function params basically works - fine tuning needed --- builtin.py | 3 ++- functions.py | 4 +--- plugin/jedi.vim | 12 ++++++++++-- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/builtin.py b/builtin.py index e388fd7b..7abfa675 100644 --- a/builtin.py +++ b/builtin.py @@ -172,7 +172,8 @@ class Parser(CachedModule): name = self.name if name == '__builtin__' and not is_py3k: name = 'builtins' - f = open(os.path.sep.join(['mixin', name]) + '.py') + path = os.path.dirname(os.path.abspath(__file__)) + f = open(os.path.sep.join([path, 'mixin', name]) + '.py') except IOError: return {} else: diff --git a/functions.py b/functions.py index 0369f925..1ea8d2c0 100644 --- a/functions.py +++ b/functions.py @@ -124,10 +124,8 @@ class CallDef(object): else: try: sub = self.executable.get_subscope_by_name('__init__') - return sub.params + return sub.params[1:] # ignore self except KeyError: - print self.executable.subscopes - print 'LALA' return [] def __repr__(self): diff --git a/plugin/jedi.vim b/plugin/jedi.vim index 29e91621..b0bbc480 100644 --- a/plugin/jedi.vim +++ b/plugin/jedi.vim @@ -465,6 +465,9 @@ def show_func_def(call_def, completion_lines=0): row, column = vim.current.window.cursor vim.eval('jedi#clear_func_def()') + if call_def is None: + return + if column < 2 or row == 0: return # edge cases, just ignore @@ -473,8 +476,13 @@ def show_func_def(call_def, completion_lines=0): insert_column = column - 2 # because it has stuff at the beginning - print call_def, call_def.params - text = " (*asdf*, basdf) " + params = [p.get_code().replace('\n', '') for p in call_def.params] + try: + params[call_def.index] = '*%s*' % params[call_def.index] + except IndexError: + pass + + text = " (%s) " % ', '.join(params) text = ' ' * (insert_column - len(line)) + text end_column = insert_column + len(text) - 2 # -2 because of bold symbols # replace line before with cursor