Make powerline.vim work in compatible mode
This commit is contained in:
parent
1fbd92bb88
commit
536427f4be
|
@ -3,39 +3,41 @@ if exists('g:powerline_loaded')
|
|||
endif
|
||||
let g:powerline_loaded = 1
|
||||
|
||||
function! s:CriticalError(message)
|
||||
echohl ErrorMsg
|
||||
echomsg a:message
|
||||
echohl None
|
||||
endfunction
|
||||
|
||||
if ! has('python') && ! has('python3')
|
||||
if !exists('g:powerline_no_python_error')
|
||||
call s:CriticalError('You need vim compiled with Python 2.6+ or 3.2+ support
|
||||
\ for Powerline to work. Please consult the documentation for more details.')
|
||||
echohl ErrorMsg
|
||||
echom 'You need vim compiled with Python 2.6, 2.7 or 3.2 and later support'
|
||||
echom 'for Powerline to work. Please consult the documentation for more'
|
||||
echom 'details.'
|
||||
echohl None
|
||||
endif
|
||||
finish
|
||||
endif
|
||||
|
||||
let s:pycmd = substitute(get(g:, 'powerline_pycmd', has('python') ? 'py' : 'py3'),
|
||||
\'\v^(py)%[thon](3?)$', '\1\2', '')
|
||||
let s:pycmd = substitute(get(g:, 'powerline_pycmd', has('python') ? 'py' : 'py3'), '\v^(py)%[thon](3?)$', '\1\2', '')
|
||||
let s:pyeval = get(g:, 'powerline_pyeval', s:pycmd.'eval')
|
||||
|
||||
let s:import_cmd = 'from powerline.vim import setup as powerline_setup'
|
||||
try
|
||||
execute s:pycmd "try:\n"
|
||||
\ ." ".s:import_cmd."\n"
|
||||
\ ."except ImportError:\n"
|
||||
\ ." import sys, vim\n"
|
||||
\ ." sys.path.append(vim.eval('expand(\"<sfile>:h:h:h:h:h\")'))\n"
|
||||
\ ." ".s:import_cmd
|
||||
let s:pystr = "try:\n"
|
||||
let s:pystr .= " ".s:import_cmd."\n"
|
||||
let s:pystr .= "except ImportError:\n"
|
||||
let s:pystr .= " import sys, vim\n"
|
||||
let s:pystr .= " sys.path.append(vim.eval('expand(\"<sfile>:h:h:h:h:h\")'))\n"
|
||||
let s:pystr .= " ".s:import_cmd."\n"
|
||||
execute s:pycmd s:pystr
|
||||
unlet s:pystr
|
||||
let s:launched = 1
|
||||
finally
|
||||
if !exists('s:launched')
|
||||
call s:CriticalError('An error occurred while importing the Powerline package.
|
||||
\ This could be caused by an invalid sys.path setting, or by an incompatible
|
||||
\ Python version (Powerline requires Python 2.6+ or 3.2+ to work). Please consult
|
||||
\ the troubleshooting section in the documentation for possible solutions.')
|
||||
echohl ErrorMsg
|
||||
echom 'An error occurred while importing powerline package.'
|
||||
echom 'This could be caused by invalid sys.path setting,'
|
||||
echom 'or by an incompatible Python version (powerline requires'
|
||||
echom 'Python 2.6, 2.7 or 3.2 and later to work). Please consult'
|
||||
echom 'the troubleshooting section in the documentation for'
|
||||
echom 'possible solutions.'
|
||||
echohl None
|
||||
finish
|
||||
else
|
||||
unlet s:launched
|
||||
|
|
Loading…
Reference in New Issue