Make initialize.py more robust

Ref: https://github.com/davidhalter/jedi-vim/issues/574
This commit is contained in:
Daniel Hahler
2016-05-28 20:46:02 +02:00
parent 8334e505b3
commit 19ad3063d9

View File

@@ -1,23 +1,20 @@
''' ------------------------------------------------------------------------ """Python initialization for jedi module."""
Python initialization
---------------------------------------------------------------------------
here we initialize the jedi stuff '''
import vim try:
import traceback
except Exception as excinfo:
raise Exception('Failed to import traceback: {0}'.format(excinfo))
# update the system path, to include the jedi path try:
import sys import os, sys, vim
import os jedi_path = os.path.join(vim.eval('expand(s:script_path)'), 'jedi')
sys.path.insert(0, jedi_path)
jedi_vim_path = vim.eval('expand(s:script_path)')
sys.path.insert(0, jedi_vim_path)
except Exception as excinfo:
raise Exception('Failed to add to sys.path: {0}\n{1}'.format(
excinfo, traceback.format_exc()))
# vim.command('echom expand("<sfile>:p:h:h")') # broken, <sfile> inside function
# sys.path.insert(0, os.path.join(vim.eval('expand("<sfile>:p:h:h")'), 'jedi'))
sys.path.insert(0, os.path.join(vim.eval('expand(s:script_path)'), 'jedi'))
# to display errors correctly
import traceback
# update the sys path to include the jedi_vim script
sys.path.insert(0, vim.eval('expand(s:script_path)'))
try: try:
import jedi_vim import jedi_vim
except Exception as excinfo: except Exception as excinfo: