forked from VimPlug/jedi-vim
basic functionality of vim-jedi goto plugin
This commit is contained in:
31
jedi.vim
31
jedi.vim
@@ -75,33 +75,46 @@ endfunction
|
|||||||
function! jedi#goto()
|
function! jedi#goto()
|
||||||
python << PYTHONEOF
|
python << PYTHONEOF
|
||||||
if 1:
|
if 1:
|
||||||
|
def echo_highlight(msg):
|
||||||
|
vim.command('echohl WarningMsg | echo "%s" | echohl None' % msg)
|
||||||
|
|
||||||
row, column = vim.current.window.cursor
|
row, column = vim.current.window.cursor
|
||||||
buf_path = vim.current.buffer.name
|
buf_path = vim.current.buffer.name
|
||||||
source = '\n'.join(vim.current.buffer)
|
source = '\n'.join(vim.current.buffer)
|
||||||
try:
|
try:
|
||||||
definitions = functions.goto(source, row, column, buf_path)
|
definitions = functions.goto(source, row, column, buf_path)
|
||||||
except functions.NotFoundError:
|
except functions.NotFoundError:
|
||||||
msg = 'There is no useful expression under the cursor'
|
echo_highlight("Couldn't find a place to goto.")
|
||||||
except Exception:
|
except Exception:
|
||||||
# print to stdout, will be in :messages
|
# print to stdout, will be in :messages
|
||||||
|
echo_highlight("Some different eror, this shouldn't happen.")
|
||||||
print(traceback.format_exc())
|
print(traceback.format_exc())
|
||||||
msg = "Some different eror, this shouldn't happen"
|
|
||||||
else:
|
else:
|
||||||
msg = ', '.join(sorted(str(d) for d in definitions))
|
if not definitions:
|
||||||
if not msg:
|
echo_highlight("Couldn't find any definitions for this.")
|
||||||
msg = "No definitions found!"
|
elif len(definitions) == 1:
|
||||||
vim.command('''echomsg "%s"''' % msg)
|
d = definitions[0]
|
||||||
|
if d.module_path != vim.current.buffer.name:
|
||||||
|
vim.command('edit ' + d.module_path)
|
||||||
|
vim.current.window.cursor = d.line_nr, d.column
|
||||||
|
else:
|
||||||
|
# multiple solutions
|
||||||
|
echo_highlight("Multiple solutions: Not implemented yet.")
|
||||||
|
|
||||||
#print 'end', strout
|
#print 'end', strout
|
||||||
PYTHONEOF
|
PYTHONEOF
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! jedi#tab()
|
||||||
|
|
||||||
|
endfunction
|
||||||
|
|
||||||
" ------------------------------------------------------------------------
|
" ------------------------------------------------------------------------
|
||||||
" Initialization of Jedi
|
" Initialization of jedi-vim
|
||||||
" ------------------------------------------------------------------------
|
" ------------------------------------------------------------------------
|
||||||
|
|
||||||
" defaults for jedi
|
" default for jedi-vim
|
||||||
let g:use_tabs_not_buffers = 0
|
let g:jedi#use_tabs_not_buffers = 0
|
||||||
|
|
||||||
let s:current_file=expand("<sfile>")
|
let s:current_file=expand("<sfile>")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user