From 981a400b0f46ff17cf5a2be40f60d373d570256c Mon Sep 17 00:00:00 2001 From: David Halter Date: Sun, 13 May 2012 15:19:08 +0200 Subject: [PATCH] show_definition added to vim interface --- jedi.vim | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/jedi.vim b/jedi.vim index 9e42046..8b77c55 100644 --- a/jedi.vim +++ b/jedi.vim @@ -51,6 +51,34 @@ PYTHONEOF endfunction +" ------------------------------------------------------------------------ +" get_definition +" ------------------------------------------------------------------------ +" +function! jedi#show_definition() +python << PYTHONEOF +if 1: + row, column = vim.current.window.cursor + buf_path = vim.current.buffer.name + source = '\n'.join(vim.current.buffer) + try: + definitions = functions.get_definitions(source, row, column, buf_path) + except functions.NotFoundError: + msg = 'There is no useful expression under the cursor' + except Exception: + # print to stdout, will be in :messages + print(traceback.format_exc()) + msg = "Some different eror, this shouldn't happen" + else: + msg = ', '.join(sorted(str(d) for d in definitions)) + if not msg: + msg = "No definitions found!" + vim.command('''echomsg "%s"''' % msg) + + #print 'end', strout +PYTHONEOF +endfunction + " ------------------------------------------------------------------------ " Initialization of Jedi " ------------------------------------------------------------------------