Merge remote-tracking branch 'zyx-i/fix-516' into develop

This commit is contained in:
Kim Silkebækken 2013-06-28 14:26:33 +02:00
commit c1ae7f3598
6 changed files with 72 additions and 14 deletions

2
.gitignore vendored
View File

@ -7,3 +7,5 @@ __pycache__
*.egg-info
dist
build
message.fail

View File

@ -40,17 +40,22 @@ else:
vim_get_func = VimFunc
if hasattr(vim, 'vars'):
def vim_getvar(varname):
return vim.vars[str(varname)]
elif hasattr(vim, 'bindeval'):
_vim_globals = vim.bindeval('g:')
# It may crash on some old vim versions and I do not remember in which patch
# I fixed this crash.
if hasattr(vim, 'vars') and vim.vvars['version'] > 703:
_vim_to_python_types = {
vim.Dictionary: lambda value: dict(((key, _vim_to_python(value[key])) for key in value.keys())),
vim.List: lambda value: [_vim_to_python(item) for item in value],
vim.Function: lambda _: None,
}
def vim_getvar(varname): # NOQA
try:
return _vim_globals[str(varname)]
except (KeyError, IndexError):
raise KeyError(varname)
_id = lambda value: value
def _vim_to_python(value):
return _vim_to_python_types.get(type(value), _id)(value)
def vim_getvar(varname):
return _vim_to_python(vim.vars[str(varname)])
else:
_vim_exists = vim_get_func('exists', rettype=int)

View File

@ -10,7 +10,12 @@ done
if ! ${PYTHON} scripts/powerline-lint -p powerline/config_files ; then
FAILED=1
fi
if ! vim -S tests/test_plugin_file.vim ; then
FAILED=1
fi
for script in tests/*.vim ; do
if ! vim -u NONE -S $script || test -f message.fail ; then
echo "Failed script $script" >&2
cat message.fail >&2
rm message.fail
FAILED=1
fi
done
exit $FAILED

38
tests/test_local_overrides.vim Executable file
View File

@ -0,0 +1,38 @@
#!/usr/bin/vim -S
let g:powerline_config_path = expand('<sfile>:p:h:h') . '/powerline/config_files'
let g:powerline_config_overrides = {'common': {'dividers': {'left': {'hard': ' ', 'soft': ' > '}, 'right': {'hard': ' ', 'soft': ' < '}}}}
let g:powerline_theme_overrides__default = {'segment_data': {'line_current_symbol': {'contents': 'LN '}, 'branch': {'before': 'B '}}}
try
python import powerline.vim
let pycmd = 'python'
catch
try
python3 import powerline.vim
let pycmd = 'python3'
catch
call writefile(['Unable to determine python version', v:exception], 'message.fail')
cquit
endtry
endtry
try
execute pycmd 'powerline.vim.setup()'
catch
call writefile(['Failed to run setup function', v:exception], 'message.fail')
cquit
endtry
try
let &columns = 80
let result = eval(&statusline[2:])
catch
call writefile(['Exception while evaluating &stl', v:exception], 'message.fail')
cquit
endtry
if result isnot# '%#Pl_22_24320_148_11523840_bold# NORMAL %#Pl_148_11523840_236_3158064_NONE# %#Pl_231_16777215_236_3158064_NONE#                                                 %#Pl_247_10395294_236_3158064_NONE#unix%#Pl_240_5789784_236_3158064_NONE# %#Pl_160_15485749_240_5789784_NONE# 100%%%#Pl_252_13684944_240_5789784_NONE# %#Pl_235_2500134_252_13684944_NONE# LN %#Pl_235_2500134_252_13684944_bold#  1%#Pl_22_24320_252_13684944_NONE#:1  '
call writefile(['Unexpected result', result], 'message.fail')
cquit
endif
qall!

View File

@ -3,6 +3,7 @@ set nocompatible
try
source powerline/bindings/vim/plugin/powerline.vim
catch
call writefile([v:exception], 'message.fail')
cquit
endtry
set ls=2
@ -10,7 +11,9 @@ redrawstatus!
redir =>mes
messages
redir END
if len(split(mes, "\n"))>1
let mess=split(mes, "\n")
if len(mess)>1
call writefile(mess, 'message.fail')
cquit
endif
quit!

View File

@ -1,6 +1,7 @@
# vim:fileencoding=utf-8:noet
_log = []
vars = {}
vvars = {'version': 703}
_window = 0
_mode = 'n'
_buf_purge_events = set()
@ -175,6 +176,10 @@ def eval(expr):
def bindeval(expr):
if expr == 'g:':
return vars
elif expr == '{}':
return {}
elif expr == '[]':
return []
import re
match = re.compile(r'^function\("([^"\\]+)"\)$').match(expr)
if match: