mirror of
https://github.com/davidhalter/jedi-vim.git
synced 2025-12-06 10:54:22 +08:00
Python alias works now
This commit is contained in:
@@ -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__")
|
||||
|
||||
@@ -52,9 +52,9 @@ if g:jedi#auto_initialization
|
||||
endif
|
||||
|
||||
if has('python')
|
||||
command! Python python
|
||||
command! -nargs=1 Python python <args>
|
||||
else
|
||||
command! Python python3
|
||||
command! -nargs=1 Python python3 <args>
|
||||
end
|
||||
|
||||
" vim: set et ts=4:
|
||||
|
||||
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user