Merge pull request #1025 from ZyX-I/fix-vim-troubleshooting
Fix some issues in Vim troubleshooting code
This commit is contained in:
commit
8394066298
powerline/bindings/vim/plugin
|
@ -62,14 +62,21 @@ endfunction
|
|||
try
|
||||
let s:can_replace_pyeval = !exists('g:powerline_pyeval')
|
||||
call s:rcmd("try:")
|
||||
call s:rcmd(" ".s:import_cmd."")
|
||||
call s:rcmd("except ImportError:")
|
||||
call s:rcmd(" import sys, vim")
|
||||
call s:rcmd(" sys.path.append(vim.eval('expand(\"<sfile>:h:h:h:h:h\")'))")
|
||||
call s:rcmd(" ".s:import_cmd."")
|
||||
call s:rcmd("import vim")
|
||||
call s:rcmd("VimPowerline().setup(pyeval=vim.eval('s:pyeval'), pycmd=vim.eval('s:pycmd'), can_replace_pyeval=int(vim.eval('s:can_replace_pyeval')))")
|
||||
call s:rcmd("del VimPowerline")
|
||||
call s:rcmd(" powerline_appended_path = None")
|
||||
call s:rcmd(" try:")
|
||||
call s:rcmd(" ".s:import_cmd."")
|
||||
call s:rcmd(" except ImportError:")
|
||||
call s:rcmd(" import sys, vim")
|
||||
call s:rcmd(" powerline_appended_path = vim.eval('expand(\"<sfile>:h:h:h:h:h\")')")
|
||||
call s:rcmd(" sys.path.append(powerline_appended_path)")
|
||||
call s:rcmd(" ".s:import_cmd."")
|
||||
call s:rcmd(" import vim")
|
||||
call s:rcmd(" VimPowerline().setup(pyeval=vim.eval('s:pyeval'), pycmd=vim.eval('s:pycmd'), can_replace_pyeval=int(vim.eval('s:can_replace_pyeval')))")
|
||||
call s:rcmd(" del VimPowerline")
|
||||
call s:rcmd("except Exception:")
|
||||
call s:rcmd(" import traceback, sys")
|
||||
call s:rcmd(" traceback.print_exc(file=sys.stdout)")
|
||||
call s:rcmd(" raise")
|
||||
execute s:pycmd s:pystr
|
||||
unlet s:pystr
|
||||
let s:launched = 1
|
||||
|
@ -90,42 +97,45 @@ finally
|
|||
echomsg 'should set g:powerline_pycmd to "py3" to make it load correctly.'
|
||||
endif
|
||||
echohl None
|
||||
call s:rcmd( "def powerline_troubleshoot():")
|
||||
call s:rcmd( " import sys")
|
||||
call s:rcmd( " if sys.version_info < (2, 6):")
|
||||
call s:rcmd( " print('Too old python version: ' + sys.version + ' (first supported is 2.6)')")
|
||||
call s:rcmd( " elif sys.version_info[0] == 3 and sys.version_info[1] < 2:")
|
||||
call s:rcmd( " print('Too old python 3 version: ' + sys.version + ' (first supported is 3.2)')")
|
||||
call s:rcmd( " try:")
|
||||
call s:rcmd( " import powerline")
|
||||
call s:rcmd( " except ImportError:")
|
||||
call s:rcmd( " print('Unable to import powerline, is it installed?')")
|
||||
if strpart(expand('<sfile>'), 0, 5) !=# '/usr/'
|
||||
call s:rcmd(" else:")
|
||||
call s:rcmd(" import os")
|
||||
call s:rcmd(" powerline_dir = os.path.dirname(os.path.realpath(powerline.__file__))")
|
||||
call s:rcmd(" this_dir = os.path.dirname(os.path.realpath(vim.eval('expand(\"<sfile>:p\")')))")
|
||||
call s:rcmd(" this_dir = os.path.dirname(os.path.dirname(os.path.dirname(this_dir)))")
|
||||
call s:rcmd(" if os.path.basename(this_dir) != 'powerline':")
|
||||
call s:rcmd(" print('Check your installation:')")
|
||||
call s:rcmd(" print('this script is not in powerline[/bindings/vim/plugin] directory,')")
|
||||
call s:rcmd(" print('neither it is installed system-wide')")
|
||||
call s:rcmd(" this_dir = os.path.dirname(this_dir)")
|
||||
call s:rcmd(" real_powerline_dir = os.path.realpath(powerline_dir)")
|
||||
call s:rcmd(" real_this_dir = os.path.realpath(this_dir)")
|
||||
call s:rcmd(" if real_this_dir != sys.path[-1]:")
|
||||
call s:rcmd(" print('Check your installation:')")
|
||||
call s:rcmd(" print('this script is symlinked somewhere where powerline is not present.')")
|
||||
call s:rcmd(" elif real_powerline_dir != real_this_dir:")
|
||||
call s:rcmd(" print('It appears that you have two powerline versions installed:')")
|
||||
call s:rcmd(" print('one in ' + real_powerline_dir + ', other in ' + real_this_dir + '.')")
|
||||
call s:rcmd(" print('You should remove one of this. Check out troubleshooting section,')")
|
||||
call s:rcmd(" print('it contains some information about the alternatives.')")
|
||||
endif
|
||||
call s:rcmd( "try:")
|
||||
call s:rcmd( " powerline_troubleshoot()")
|
||||
call s:rcmd( "finally:")
|
||||
call s:rcmd( " del powerline_troubleshoot")
|
||||
call s:rcmd("def powerline_troubleshoot():")
|
||||
call s:rcmd(" import sys")
|
||||
call s:rcmd(" if sys.version_info < (2, 6):")
|
||||
call s:rcmd(" print('Too old python version: ' + sys.version + ' (first supported is 2.6)')")
|
||||
call s:rcmd(" elif sys.version_info[0] == 3 and sys.version_info[1] < 2:")
|
||||
call s:rcmd(" print('Too old python 3 version: ' + sys.version + ' (first supported is 3.2)')")
|
||||
call s:rcmd(" try:")
|
||||
call s:rcmd(" import powerline")
|
||||
call s:rcmd(" except ImportError:")
|
||||
call s:rcmd(" print('Unable to import powerline, is it installed?')")
|
||||
call s:rcmd(" else:")
|
||||
call s:rcmd(" if not vim.eval('expand(\"<sfile>\")').startswith('/usr/'):")
|
||||
call s:rcmd(" import os")
|
||||
call s:rcmd(" powerline_dir = os.path.realpath(os.path.normpath(powerline.__file__))")
|
||||
call s:rcmd(" powerline_dir = os.path.dirname(powerline.__file__)")
|
||||
call s:rcmd(" this_dir = os.path.realpath(os.path.normpath(vim.eval('expand(\"<sfile>:p\")')))")
|
||||
call s:rcmd(" this_dir = os.path.dirname(this_dir)") " powerline/bindings/vim/plugin
|
||||
call s:rcmd(" this_dir = os.path.dirname(this_dir)") " powerline/bindings/vim
|
||||
call s:rcmd(" this_dir = os.path.dirname(this_dir)") " powerline/bindings
|
||||
call s:rcmd(" this_dir = os.path.dirname(this_dir)") " powerline
|
||||
call s:rcmd(" if os.path.basename(this_dir) != 'powerline':")
|
||||
call s:rcmd(" print('Check your installation:')")
|
||||
call s:rcmd(" print('this script is not in powerline[/bindings/vim/plugin] directory,')")
|
||||
call s:rcmd(" print('neither it is installed system-wide')")
|
||||
call s:rcmd(" real_powerline_dir = os.path.realpath(powerline_dir)")
|
||||
call s:rcmd(" real_this_dir = os.path.realpath(this_dir)")
|
||||
call s:rcmd(" if powerline_appended_path is not None and real_this_dir != powerline_appended_path:")
|
||||
call s:rcmd(" print('Check your installation: this script is symlinked somewhere')")
|
||||
call s:rcmd(" print('where powerline is not present: {0!r} != {1!r}.'.format(")
|
||||
call s:rcmd(" real_this_dir, sys.path[-1]))")
|
||||
call s:rcmd(" elif real_powerline_dir != real_this_dir:")
|
||||
call s:rcmd(" print('It appears that you have two powerline versions installed:')")
|
||||
call s:rcmd(" print('one in ' + real_powerline_dir + ', other in ' + real_this_dir + '.')")
|
||||
call s:rcmd(" print('You should remove one of this. Check out troubleshooting section,')")
|
||||
call s:rcmd(" print('it contains some information about the alternatives.')")
|
||||
call s:rcmd("try:")
|
||||
call s:rcmd(" powerline_troubleshoot()")
|
||||
call s:rcmd("finally:")
|
||||
call s:rcmd(" del powerline_troubleshoot")
|
||||
execute s:pycmd s:pystr
|
||||
unlet s:pystr
|
||||
unlet s:pycmd
|
||||
|
|
Loading…
Reference in New Issue