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 *.egg-info
dist dist
build build
message.fail

View File

@ -40,17 +40,22 @@ else:
vim_get_func = VimFunc vim_get_func = VimFunc
if hasattr(vim, 'vars'): # It may crash on some old vim versions and I do not remember in which patch
def vim_getvar(varname): # I fixed this crash.
return vim.vars[str(varname)] if hasattr(vim, 'vars') and vim.vvars['version'] > 703:
elif hasattr(vim, 'bindeval'): _vim_to_python_types = {
_vim_globals = vim.bindeval('g:') 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 _id = lambda value: value
try:
return _vim_globals[str(varname)] def _vim_to_python(value):
except (KeyError, IndexError): return _vim_to_python_types.get(type(value), _id)(value)
raise KeyError(varname)
def vim_getvar(varname):
return _vim_to_python(vim.vars[str(varname)])
else: else:
_vim_exists = vim_get_func('exists', rettype=int) _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 if ! ${PYTHON} scripts/powerline-lint -p powerline/config_files ; then
FAILED=1 FAILED=1
fi fi
if ! vim -S tests/test_plugin_file.vim ; then for script in tests/*.vim ; do
FAILED=1 if ! vim -u NONE -S $script || test -f message.fail ; then
fi echo "Failed script $script" >&2
cat message.fail >&2
rm message.fail
FAILED=1
fi
done
exit $FAILED 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 try
source powerline/bindings/vim/plugin/powerline.vim source powerline/bindings/vim/plugin/powerline.vim
catch catch
call writefile([v:exception], 'message.fail')
cquit cquit
endtry endtry
set ls=2 set ls=2
@ -10,7 +11,9 @@ redrawstatus!
redir =>mes redir =>mes
messages messages
redir END redir END
if len(split(mes, "\n"))>1 let mess=split(mes, "\n")
if len(mess)>1
call writefile(mess, 'message.fail')
cquit cquit
endif endif
quit! quit!

View File

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