Use g:powerline_theme_overrides dictionary in place of g:…overrides__

Ref #1126
This commit is contained in:
ZyX 2015-01-06 20:48:39 +03:00
parent 28ec9a5117
commit 1c29ea3f8c
3 changed files with 14 additions and 11 deletions

View File

@ -16,11 +16,11 @@ Vim configuration can be overridden using the following options:
Dictionary, recursively merged with contents of Dictionary, recursively merged with contents of
:file:`powerline/config.json`. :file:`powerline/config.json`.
``g:powerline_theme_overrides__{theme_name}`` ``g:powerline_theme_overrides``
Dictionary, recursively merged with contents of Dictionary mapping theme names to theme overrides, recursively merged with
:file:`powerline/themes/vim/{theme_name}.json`. Note that this way you cant contents of :file:`powerline/themes/vim/{key}.json`. Note that this way you
redefine some value (e.g. segment) in list, only the whole list itself: only cant redefine some value (e.g. segment) in list, only the whole list
dictionaries are merged recursively. itself: only dictionaries are merged recursively.
``g:powerline_config_paths`` ``g:powerline_config_paths``
Paths list (each path must be expanded, ``~`` shortcut is not supported). Paths list (each path must be expanded, ``~`` shortcut is not supported).

View File

@ -15,11 +15,16 @@ from powerline.lib.dict import mergedicts
from powerline.lib.unicode import u from powerline.lib.unicode import u
def _override_from(config, override_varname): def _override_from(config, override_varname, key=None):
try: try:
overrides = vim_getvar(override_varname) overrides = vim_getvar(override_varname)
except KeyError: except KeyError:
return config return config
if key is not None:
try:
overrides = overrides[key]
except KeyError:
return config
mergedicts(config, overrides) mergedicts(config, overrides)
return config return config
@ -111,12 +116,10 @@ class VimPowerline(Powerline):
return _override_from(super(VimPowerline, self).load_main_config(), 'powerline_config_overrides') return _override_from(super(VimPowerline, self).load_main_config(), 'powerline_config_overrides')
def load_theme_config(self, name): def load_theme_config(self, name):
# Note: themes with non-[a-zA-Z0-9_] names are impossible to override
# (though as far as I know exists() wont throw). Wont fix, use proper
# theme names.
return _override_from( return _override_from(
super(VimPowerline, self).load_theme_config(name), super(VimPowerline, self).load_theme_config(name),
'powerline_theme_overrides__' + name 'powerline_theme_overrides',
name
) )
def get_local_themes(self, local_themes): def get_local_themes(self, local_themes):

View File

@ -2,7 +2,7 @@
set encoding=utf-8 set encoding=utf-8
let g:powerline_config_paths = [expand('<sfile>:p:h:h') . '/powerline/config_files'] let g:powerline_config_paths = [expand('<sfile>:p:h:h') . '/powerline/config_files']
let g:powerline_config_overrides = {'common': {'default_top_theme': 'ascii'}} let g:powerline_config_overrides = {'common': {'default_top_theme': 'ascii'}}
let g:powerline_theme_overrides__default = {'segment_data': {'line_current_symbol': {'contents': 'LN '}, 'branch': {'before': 'B '}}} let g:powerline_theme_overrides = {'default': {'segment_data': {'line_current_symbol': {'contents': 'LN '}, 'branch': {'before': 'B '}}}}
redir => g:messages redir => g:messages