Merge pull request #577 from blueyed/more-robust-initialize.py

Make initialize.py more robust
This commit is contained in:
Dave Halter
2016-06-16 21:18:44 +02:00
committed by GitHub

View File

@@ -1,23 +1,20 @@
''' ------------------------------------------------------------------------
Python initialization
---------------------------------------------------------------------------
here we initialize the jedi stuff '''
"""Python initialization for jedi module."""
import vim
# update the system path, to include the jedi path
import sys
import os
# 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
try:
import traceback
except Exception as excinfo:
raise Exception('Failed to import traceback: {0}'.format(excinfo))
try:
import os, sys, vim
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()))
# update the sys path to include the jedi_vim script
sys.path.insert(0, vim.eval('expand(s:script_path)'))
try:
import jedi_vim
except Exception as excinfo: