mirror of
https://github.com/davidhalter/jedi-vim.git
synced 2025-12-09 20:15:01 +08:00
module imports are working now
This commit is contained in:
18
jedi.vim
18
jedi.vim
@@ -10,6 +10,9 @@ if !has('python')
|
|||||||
finish
|
finish
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
" ------------------------------------------------------------------------
|
||||||
|
" Completion
|
||||||
|
" ------------------------------------------------------------------------
|
||||||
|
|
||||||
function! jedi#Complete(findstart, base)
|
function! jedi#Complete(findstart, base)
|
||||||
if a:findstart == 1
|
if a:findstart == 1
|
||||||
@@ -17,17 +20,19 @@ function! jedi#Complete(findstart, base)
|
|||||||
else
|
else
|
||||||
python << PYTHONEOF
|
python << PYTHONEOF
|
||||||
if 1:
|
if 1:
|
||||||
|
# TODO change the finstart column, to switch cases, if they are not right.
|
||||||
row, column = vim.current.window.cursor
|
row, column = vim.current.window.cursor
|
||||||
|
buf_path = vim.current.buffer.name
|
||||||
source = '\n'.join(vim.current.buffer)
|
source = '\n'.join(vim.current.buffer)
|
||||||
try:
|
try:
|
||||||
completions = functions.complete(source, row, column)
|
completions = functions.complete(source, row, column, buf_path)
|
||||||
out = []
|
out = []
|
||||||
for c in completions:
|
for c in completions:
|
||||||
d = dict(word=c.complete,
|
d = dict(word=c.complete,
|
||||||
abbr=str(c),
|
abbr=str(c),
|
||||||
menu=c.description, # stuff directly behind the completion
|
menu=c.description, # stuff directly behind the completion
|
||||||
info=c.help, # docstr and similar stuff
|
info=c.help, # docstr and similar stuff
|
||||||
kind=c.type, # completion type
|
kind=c.get_vim_type(), # completion type
|
||||||
icase=1, # case insensitive
|
icase=1, # case insensitive
|
||||||
dup=1, # allow duplicates (maybe later remove this)
|
dup=1, # allow duplicates (maybe later remove this)
|
||||||
)
|
)
|
||||||
@@ -35,10 +40,11 @@ if 1:
|
|||||||
|
|
||||||
strout = str(out)
|
strout = str(out)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print 'error:', e
|
# print to stdout, will be in :messages
|
||||||
|
print(traceback.format_exc())
|
||||||
strout = ''
|
strout = ''
|
||||||
|
|
||||||
print 'end', strout
|
#print 'end', strout
|
||||||
vim.command('return ' + strout)
|
vim.command('return ' + strout)
|
||||||
PYTHONEOF
|
PYTHONEOF
|
||||||
endif
|
endif
|
||||||
@@ -48,7 +54,7 @@ endfunction
|
|||||||
" ------------------------------------------------------------------------
|
" ------------------------------------------------------------------------
|
||||||
" Initialization of Jedi
|
" Initialization of Jedi
|
||||||
" ------------------------------------------------------------------------
|
" ------------------------------------------------------------------------
|
||||||
"
|
|
||||||
let s:current_file=expand("<sfile>")
|
let s:current_file=expand("<sfile>")
|
||||||
|
|
||||||
python << PYTHONEOF
|
python << PYTHONEOF
|
||||||
@@ -60,6 +66,8 @@ import sys
|
|||||||
from os.path import dirname
|
from os.path import dirname
|
||||||
sys.path.insert(0, dirname(dirname(vim.eval('s:current_file'))))
|
sys.path.insert(0, dirname(dirname(vim.eval('s:current_file'))))
|
||||||
|
|
||||||
|
import traceback # for exception output
|
||||||
|
|
||||||
import functions
|
import functions
|
||||||
PYTHONEOF
|
PYTHONEOF
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user