commit
116af44b1f
|
@ -43,7 +43,7 @@ else:
|
||||||
|
|
||||||
# It may crash on some old vim versions and I do not remember in which patch
|
# It may crash on some old vim versions and I do not remember in which patch
|
||||||
# I fixed this crash.
|
# I fixed this crash.
|
||||||
if hasattr(vim, 'vars') and vim.vvars['version'] > 703:
|
if hasattr(vim, 'vvars') and vim.vvars['version'] > 703:
|
||||||
_vim_to_python_types = {
|
_vim_to_python_types = {
|
||||||
vim.Dictionary: lambda value: dict(((key, _vim_to_python(value[key])) for key in value.keys())),
|
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.List: lambda value: [_vim_to_python(item) for item in value],
|
||||||
|
@ -57,6 +57,13 @@ if hasattr(vim, 'vars') and vim.vvars['version'] > 703:
|
||||||
|
|
||||||
def vim_getvar(varname):
|
def vim_getvar(varname):
|
||||||
return _vim_to_python(vim.vars[str(varname)])
|
return _vim_to_python(vim.vars[str(varname)])
|
||||||
|
|
||||||
|
def bufvar_exists(buffer, varname):
|
||||||
|
buffer = buffer or vim.current.buffer
|
||||||
|
return varname in buffer.vars
|
||||||
|
|
||||||
|
def vim_getwinvar(segment_info, varname):
|
||||||
|
return _vim_to_python(segment_info['window'].vars[str(varname)])
|
||||||
else:
|
else:
|
||||||
_vim_exists = vim_get_func('exists', rettype=int)
|
_vim_exists = vim_get_func('exists', rettype=int)
|
||||||
|
|
||||||
|
@ -67,11 +74,6 @@ else:
|
||||||
else:
|
else:
|
||||||
raise KeyError(varname)
|
raise KeyError(varname)
|
||||||
|
|
||||||
if hasattr(vim, 'vars') and vim.vvars['version'] > 703:
|
|
||||||
def bufvar_exists(buffer, varname):
|
|
||||||
buffer = buffer or vim.current.buffer
|
|
||||||
return varname in buffer.vars
|
|
||||||
else:
|
|
||||||
def bufvar_exists(buffer, varname): # NOQA
|
def bufvar_exists(buffer, varname): # NOQA
|
||||||
if not buffer or buffer.number == vim.current.buffer.number:
|
if not buffer or buffer.number == vim.current.buffer.number:
|
||||||
return vim.eval('exists("b:{0}")'.format(varname))
|
return vim.eval('exists("b:{0}")'.format(varname))
|
||||||
|
@ -79,6 +81,13 @@ else:
|
||||||
return vim.eval('has_key(getbufvar({0}, ""), {1})'
|
return vim.eval('has_key(getbufvar({0}, ""), {1})'
|
||||||
.format(buffer.number, varname))
|
.format(buffer.number, varname))
|
||||||
|
|
||||||
|
def vim_getwinvar(segment_info, varname): # NOQA
|
||||||
|
result = vim.eval('getwinvar({0}, "{1}")'.format(segment_info['winnr'], varname))
|
||||||
|
if result == '':
|
||||||
|
if not int(vim.eval('has_key(getwinvar({0}, ""), "{1}")'.format(segment_info['winnr'], varname))):
|
||||||
|
raise KeyError(varname)
|
||||||
|
return result
|
||||||
|
|
||||||
if hasattr(vim, 'options'):
|
if hasattr(vim, 'options'):
|
||||||
def vim_getbufoption(info, option):
|
def vim_getbufoption(info, option):
|
||||||
return info['buffer'].options[option]
|
return info['buffer'].options[option]
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
"branch:divider": { "fg": "gray7", "bg": "gray4" },
|
"branch:divider": { "fg": "gray7", "bg": "gray4" },
|
||||||
"file_directory": { "fg": "gray9", "bg": "gray4" },
|
"file_directory": { "fg": "gray9", "bg": "gray4" },
|
||||||
"file_name": { "fg": "white", "bg": "gray4", "attr": ["bold"] },
|
"file_name": { "fg": "white", "bg": "gray4", "attr": ["bold"] },
|
||||||
|
"window_title": { "fg": "white", "bg": "gray4" },
|
||||||
"file_size": { "fg": "gray8", "bg": "gray2" },
|
"file_size": { "fg": "gray8", "bg": "gray2" },
|
||||||
"file_name_no_file": { "fg": "gray9", "bg": "gray4", "attr": ["bold"] },
|
"file_name_no_file": { "fg": "gray9", "bg": "gray4", "attr": ["bold"] },
|
||||||
"file_name_empty": { "fg": "gray9", "bg": "gray4" },
|
"file_name_empty": { "fg": "gray9", "bg": "gray4" },
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
"branch:divider": { "fg": "gray61", "bg": "darkgreencopper" },
|
"branch:divider": { "fg": "gray61", "bg": "darkgreencopper" },
|
||||||
"file_directory": { "fg": "lightyellow", "bg": "darkgreencopper" },
|
"file_directory": { "fg": "lightyellow", "bg": "darkgreencopper" },
|
||||||
"file_name": { "fg": "oldlace", "bg": "darkgreencopper", "attr": ["bold"] },
|
"file_name": { "fg": "oldlace", "bg": "darkgreencopper", "attr": ["bold"] },
|
||||||
|
"window_title": { "fg": "oldlace", "bg": "darkgreencopper" },
|
||||||
"file_size": { "fg": "oldlace", "bg": "darkgreencopper" },
|
"file_size": { "fg": "oldlace", "bg": "darkgreencopper" },
|
||||||
"file_name_no_file": { "fg": "oldlace", "bg": "darkgreencopper", "attr": ["bold"] },
|
"file_name_no_file": { "fg": "oldlace", "bg": "darkgreencopper", "attr": ["bold"] },
|
||||||
"file_name_empty": { "fg": "oldlace", "bg": "darkgreencopper" },
|
"file_name_empty": { "fg": "oldlace", "bg": "darkgreencopper" },
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
"branch:divider": { "fg": "gray61", "bg": "lightyellow" },
|
"branch:divider": { "fg": "gray61", "bg": "lightyellow" },
|
||||||
"file_directory": { "fg": "royalblue5", "bg": "lightyellow" },
|
"file_directory": { "fg": "royalblue5", "bg": "lightyellow" },
|
||||||
"file_name": { "fg": "gray13", "bg": "lightyellow", "attr": ["bold"] },
|
"file_name": { "fg": "gray13", "bg": "lightyellow", "attr": ["bold"] },
|
||||||
|
"window_title": { "fg": "gray13", "bg": "lightyellow" },
|
||||||
"file_size": { "fg": "gray13", "bg": "lightyellow" },
|
"file_size": { "fg": "gray13", "bg": "lightyellow" },
|
||||||
"file_name_no_file": { "fg": "gray13", "bg": "lightyellow", "attr": ["bold"] },
|
"file_name_no_file": { "fg": "gray13", "bg": "lightyellow", "attr": ["bold"] },
|
||||||
"file_name_empty": { "fg": "gray13", "bg": "lightyellow" },
|
"file_name_empty": { "fg": "gray13", "bg": "lightyellow" },
|
||||||
|
|
|
@ -9,7 +9,10 @@
|
||||||
{
|
{
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"name": "buffer_name",
|
"name": "buffer_name",
|
||||||
"highlight_group": ["file_name"],
|
"highlight_group": ["file_name"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "window_title",
|
||||||
"draw_soft_divider": false
|
"draw_soft_divider": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,7 +9,7 @@ except ImportError:
|
||||||
vim = {} # NOQA
|
vim = {} # NOQA
|
||||||
|
|
||||||
from powerline.bindings.vim import (vim_get_func, getbufvar, vim_getbufoption,
|
from powerline.bindings.vim import (vim_get_func, getbufvar, vim_getbufoption,
|
||||||
buffer_name)
|
buffer_name, vim_getwinvar)
|
||||||
from powerline.theme import requires_segment_info
|
from powerline.theme import requires_segment_info
|
||||||
from powerline.lib import add_divider_highlight_group
|
from powerline.lib import add_divider_highlight_group
|
||||||
from powerline.lib.vcs import guess, tree_status
|
from powerline.lib.vcs import guess, tree_status
|
||||||
|
@ -249,6 +249,20 @@ def file_type(pl, segment_info):
|
||||||
return vim_getbufoption(segment_info, 'filetype') or None
|
return vim_getbufoption(segment_info, 'filetype') or None
|
||||||
|
|
||||||
|
|
||||||
|
@requires_segment_info
|
||||||
|
def window_title(pl, segment_info):
|
||||||
|
'''Return the window title.
|
||||||
|
|
||||||
|
This currently looks at the ``quickfix_title`` window variable,
|
||||||
|
which is used by Syntastic and Vim itself.
|
||||||
|
|
||||||
|
It is used in the quickfix theme.'''
|
||||||
|
try:
|
||||||
|
return vim_getwinvar(segment_info, 'quickfix_title')
|
||||||
|
except KeyError:
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
@requires_segment_info
|
@requires_segment_info
|
||||||
def line_percent(pl, segment_info, gradient=False):
|
def line_percent(pl, segment_info, gradient=False):
|
||||||
'''Return the cursor position in the file as a percentage.
|
'''Return the cursor position in the file as a percentage.
|
||||||
|
|
Loading…
Reference in New Issue