From 3c55a4bed67f3d404929b139a4b8471099109fd1 Mon Sep 17 00:00:00 2001 From: David Halter Date: Mon, 7 Jan 2013 00:28:37 +0100 Subject: [PATCH] Python alias works now --- autoload/jedi.vim | 23 +---------------------- plugin/jedi.vim | 4 ++-- plugin/jedi_vim.py | 22 ++++++++++++++++++++++ 3 files changed, 25 insertions(+), 24 deletions(-) diff --git a/autoload/jedi.vim b/autoload/jedi.vim index 8718383..f6cba10 100644 --- a/autoload/jedi.vim +++ b/autoload/jedi.vim @@ -46,28 +46,7 @@ endfunction " show_pydoc " ------------------------------------------------------------------------ function! jedi#show_pydoc() -Python << PYTHONEOF -if 1: - script = jedi_vim.get_script() - try: - definitions = script.get_definition() - except jedi_vim.jedi.NotFoundError: - definitions = [] - except Exception: - # print to stdout, will be in :messages - definitions = [] - print("Exception, this shouldn't happen.") - print(traceback.format_exc()) - - if not definitions: - vim.command('return') - else: - docs = ['Docstring for %s\n%s\n%s' % (d.desc_with_module, '='*40, d.doc) if d.doc - else '|No Docstring for %s|' % d for d in definitions] - text = ('\n' + '-' * 79 + '\n').join(docs) - vim.command('let l:doc = %s' % repr(jedi_vim.PythonToVimStr(text))) - vim.command('let l:doc_lines = %s' % len(text.split('\n'))) -PYTHONEOF + Python jedi_vim.show_pydoc() if bufnr("__doc__") > 0 " If the __doc__ buffer is open in the current window, jump to it silent execute "sbuffer ".bufnr("__doc__") diff --git a/plugin/jedi.vim b/plugin/jedi.vim index a1ca806..6528bfd 100644 --- a/plugin/jedi.vim +++ b/plugin/jedi.vim @@ -52,9 +52,9 @@ if g:jedi#auto_initialization endif if has('python') - command! Python python + command! -nargs=1 Python python else - command! Python python3 + command! -nargs=1 Python python3 end " vim: set et ts=4: diff --git a/plugin/jedi_vim.py b/plugin/jedi_vim.py index 5513098..cd34b29 100644 --- a/plugin/jedi_vim.py +++ b/plugin/jedi_vim.py @@ -154,6 +154,28 @@ def goto(is_definition=False, is_related_name=False, no_output=False): return definitions +def show_pydoc(): + script = get_script() + try: + definitions = script.get_definition() + except jedi.NotFoundError: + definitions = [] + except Exception: + # print to stdout, will be in :messages + definitions = [] + print("Exception, this shouldn't happen.") + print(traceback.format_exc()) + + if not definitions: + vim.command('return') + else: + docs = ['Docstring for %s\n%s\n%s' % (d.desc_with_module, '='*40, d.doc) if d.doc + else '|No Docstring for %s|' % d for d in definitions] + text = ('\n' + '-' * 79 + '\n').join(docs) + vim.command('let l:doc = %s' % repr(PythonToVimStr(text))) + vim.command('let l:doc_lines = %s' % len(text.split('\n'))) + + def clear_func_def(): cursor = vim.current.window.cursor e = vim.eval('g:jedi#function_definition_escape')