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