Fix whitespace issues so pyflakes doesn't complain

This commit is contained in:
Kim Silkebækken 2012-11-17 12:21:24 +01:00
parent 0f6d24b1e8
commit 4cb0559be4
1 changed files with 18 additions and 15 deletions

View File

@ -33,7 +33,7 @@ if hasattr(vim, 'bindeval'):
def get_vim_func(f, rettype=None): def get_vim_func(f, rettype=None):
try: try:
return vim.bindeval('function("'+f+'")') return vim.bindeval('function("' + f + '")')
except vim.error: except vim.error:
return None return None
@ -43,35 +43,38 @@ if hasattr(vim, 'bindeval'):
vim_globals[var] = val vim_globals[var] = val
else: else:
import json import json
class VimFunc(object): class VimFunc(object):
__slots__ = ('f','rettype') __slots__ = ('f', 'rettype')
def __init__(self, f, rettype=None): def __init__(self, f, rettype=None):
self.f = f self.f = f
self.rettype = rettype self.rettype = rettype
def __call__(self, *args): def __call__(self, *args):
r = vim.eval(self.f+'('+json.dumps(args)[1:-1]+')') r = vim.eval(self.f + '(' + json.dumps(args)[1:-1] + ')')
if self.rettype: if self.rettype:
return self.rettype(r) return self.rettype(r)
return r return r
get_vim_func = VimFunc get_vim_func = VimFunc
def set_global_var(var, val): def set_global_var(var, val): # NOQA
vim.command('let g:{0}={1}'.format(var, json.dumps(val))) vim.command('let g:{0}={1}'.format(var, json.dumps(val)))
vim_funcs = { vim_funcs = {
'winwidth' : get_vim_func('winwidth', rettype=int), 'winwidth': get_vim_func('winwidth', rettype=int),
'mode' : get_vim_func('mode'), 'mode': get_vim_func('mode'),
'fghead' : get_vim_func('fugitive#head'), 'fghead': get_vim_func('fugitive#head'),
'line' : get_vim_func('line', rettype=int), 'line': get_vim_func('line', rettype=int),
'col' : get_vim_func('col', rettype=int), 'col': get_vim_func('col', rettype=int),
'expand' : get_vim_func('expand'), 'expand': get_vim_func('expand'),
'tbcurtag' : get_vim_func('tagbar#currenttag'), 'tbcurtag': get_vim_func('tagbar#currenttag'),
'sstlflag' : get_vim_func('SyntasticStatuslineFlag'), 'sstlflag': get_vim_func('SyntasticStatuslineFlag'),
'hlexists' : get_vim_func('hlexists', rettype=int), 'hlexists': get_vim_func('hlexists', rettype=int),
} }
def statusline(): def statusline():
winwidth = vim_funcs['winwidth'](0) winwidth = vim_funcs['winwidth'](0)
@ -89,7 +92,7 @@ def statusline():
branch = '' + branch branch = '' + branch
line_current = vim_funcs['line']('.') line_current = vim_funcs['line']('.')
line_end = vim_funcs['line']('$') line_end = vim_funcs['line']('$')
line_percent = line_current * 100 // line_end line_percent = line_current * 100 // line_end
# Fun gradient colored percent segment # Fun gradient colored percent segment