Merge pull request #807 from ZyX-I/improved-troubleshooting
Improved troubleshooting
This commit is contained in:
commit
1faf118fa3
|
@ -99,20 +99,6 @@ My vim statusline is hidden/only appears in split windows!
|
|||
|
||||
* Make sure that you have ``set laststatus=2`` in your :file:`vimrc`.
|
||||
|
||||
I get E858/E860 error in vim (Eval did not return a valid python object)
|
||||
--------------------------------------------------------------------------
|
||||
|
||||
* You need to make ``pyeval()`` display python stack trace. There is currently
|
||||
a patch for this, but it was not merged into main vim tree, thus you will have
|
||||
to use different approach: reproduce the error with
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
vim --cmd "let g:powerline_debugging_pyeval=1" ...
|
||||
|
||||
and then use the stack trace to search for existing issues or to create a new
|
||||
one.
|
||||
|
||||
My vim statusline is not displayed completely and has too much spaces
|
||||
---------------------------------------------------------------------
|
||||
|
||||
|
|
|
@ -93,10 +93,12 @@ Installation
|
|||
Usage
|
||||
=====
|
||||
|
||||
.. _vim-vimrc:
|
||||
|
||||
Vim statusline
|
||||
--------------
|
||||
|
||||
If installed using pip just use
|
||||
If installed using pip just add
|
||||
|
||||
.. code-block:: vim
|
||||
|
||||
|
@ -104,7 +106,7 @@ If installed using pip just use
|
|||
python powerline_setup()
|
||||
python del powerline_setup
|
||||
|
||||
(replace ``python`` with ``python3`` if appropriate).
|
||||
(replace ``python`` with ``python3`` if appropriate) to your :file:`vimrc`.
|
||||
|
||||
If you just cloned the repository add the following line to your :file:`vimrc`,
|
||||
where ``{repository_root}`` is the absolute path to your Powerline installation
|
||||
|
|
|
@ -3,39 +3,78 @@ 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 !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
|
||||
echomsg 'You need vim compiled with Python 2.6, 2.7 or 3.2 and later support'
|
||||
echomsg 'for Powerline to work. Please consult the documentation for more'
|
||||
echomsg '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
|
||||
unlet s:import_cmd
|
||||
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
|
||||
echomsg 'An error occurred while importing powerline package.'
|
||||
echomsg 'This could be caused by invalid sys.path setting,'
|
||||
echomsg 'or by an incompatible Python version (powerline requires'
|
||||
echomsg 'Python 2.6, 2.7 or 3.2 and later to work). Please consult'
|
||||
echomsg 'the troubleshooting section in the documentation for'
|
||||
echomsg 'possible solutions.'
|
||||
echohl None
|
||||
let s:pystr = "def powerline_troubleshoot():\n"
|
||||
let s:pystr .= " import sys\n"
|
||||
let s:pystr .= " if sys.version_info < (2, 6):\n"
|
||||
let s:pystr .= " print('Too old python version: ' + sys.version + ' (first supported is 2.6)')\n"
|
||||
let s:pystr .= " elif sys.version_info[0] == 3 and sys.version_info[1] < 2:\n"
|
||||
let s:pystr .= " print('Too old python 3 version: ' + sys.version + ' (first supported is 3.2)')\n"
|
||||
let s:pystr .= " try:\n"
|
||||
let s:pystr .= " import powerline\n"
|
||||
let s:pystr .= " except ImportError:\n"
|
||||
let s:pystr .= " print('Unable to import powerline, is it installed?')\n"
|
||||
if expand('<sfile>')[:4] isnot# '/usr/'
|
||||
let s:pystr .= " else:\n"
|
||||
let s:pystr .= " import os\n"
|
||||
let s:pystr .= " powerline_dir = os.path.dirname(os.path.realpath(powerline.__file__))\n"
|
||||
let s:pystr .= " this_dir = os.path.dirname(os.path.realpath(vim.eval('expand(\"<sfile>:p\")')))\n"
|
||||
let s:pystr .= " this_dir = os.path.dirname(os.path.dirname(os.path.dirname(this_dir)))\n"
|
||||
let s:pystr .= " if os.path.basename(this_dir) != 'powerline':\n"
|
||||
let s:pystr .= " print('Check your installation:')\n"
|
||||
let s:pystr .= " print('this script is not in powerline[/bindings/vim/plugin] directory,')\n"
|
||||
let s:pystr .= " print('neither it is installed system-wide')\n"
|
||||
let s:pystr .= " this_dir = os.path.dirname(this_dir)\n"
|
||||
let s:pystr .= " real_powerline_dir = os.path.realpath(powerline_dir)\n"
|
||||
let s:pystr .= " real_this_dir = os.path.realpath(this_dir)\n"
|
||||
let s:pystr .= " if real_this_dir != sys.path[-1]:\n"
|
||||
let s:pystr .= " print('Check your installation:')\n"
|
||||
let s:pystr .= " print('this script is symlinked somewhere where powerline is not present.')\n"
|
||||
let s:pystr .= " elif real_powerline_dir != real_this_dir:\n"
|
||||
let s:pystr .= " print('It appears that you have two powerline versions installed:')\n"
|
||||
let s:pystr .= " print('one in ' + real_powerline_dir + ', other in ' + real_this_dir + '.')\n"
|
||||
let s:pystr .= " print('You should remove one of this. Check out troubleshooting section,')\n"
|
||||
let s:pystr .= " print('it contains some information about the alternatives.')\n"
|
||||
endif
|
||||
execute s:pycmd s:pystr
|
||||
unlet s:pystr
|
||||
unlet s:pycmd
|
||||
unlet s:pyeval
|
||||
finish
|
||||
else
|
||||
unlet s:launched
|
||||
|
@ -45,3 +84,6 @@ endtry
|
|||
execute s:pycmd 'import vim'
|
||||
execute s:pycmd 'powerline_setup(pyeval=vim.eval("s:pyeval"), pycmd=vim.eval("s:pycmd"))'
|
||||
execute s:pycmd 'del powerline_setup'
|
||||
|
||||
unlet s:pycmd
|
||||
unlet s:pyeval
|
||||
|
|
Loading…
Reference in New Issue