diff --git a/docs/source/configuration/local.rst b/docs/source/configuration/local.rst index ec56560c..1f66a1a4 100644 --- a/docs/source/configuration/local.rst +++ b/docs/source/configuration/local.rst @@ -16,11 +16,11 @@ Vim configuration can be overridden using the following options: Dictionary, recursively merged with contents of :file:`powerline/config.json`. -``g:powerline_theme_overrides__{theme_name}`` - Dictionary, recursively merged with contents of - :file:`powerline/themes/vim/{theme_name}.json`. Note that this way you can’t - redefine some value (e.g. segment) in list, only the whole list itself: only - dictionaries are merged recursively. +``g:powerline_theme_overrides`` + Dictionary mapping theme names to theme overrides, recursively merged with + contents of :file:`powerline/themes/vim/{key}.json`. Note that this way you + can’t redefine some value (e.g. segment) in list, only the whole list + itself: only dictionaries are merged recursively. ``g:powerline_config_paths`` Paths list (each path must be expanded, ``~`` shortcut is not supported). diff --git a/powerline/vim.py b/powerline/vim.py index d9cf8013..b93788a8 100644 --- a/powerline/vim.py +++ b/powerline/vim.py @@ -15,11 +15,16 @@ from powerline.lib.dict import mergedicts from powerline.lib.unicode import u -def _override_from(config, override_varname): +def _override_from(config, override_varname, key=None): try: overrides = vim_getvar(override_varname) except KeyError: return config + if key is not None: + try: + overrides = overrides[key] + except KeyError: + return config mergedicts(config, overrides) return config @@ -111,12 +116,10 @@ class VimPowerline(Powerline): return _override_from(super(VimPowerline, self).load_main_config(), 'powerline_config_overrides') 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() won’t throw). Won’t fix, use proper - # theme names. return _override_from( super(VimPowerline, self).load_theme_config(name), - 'powerline_theme_overrides__' + name + 'powerline_theme_overrides', + name ) def get_local_themes(self, local_themes): diff --git a/tests/test_local_overrides.vim b/tests/test_local_overrides.vim index f6cf0931..353c086d 100755 --- a/tests/test_local_overrides.vim +++ b/tests/test_local_overrides.vim @@ -2,7 +2,7 @@ set encoding=utf-8 let g:powerline_config_paths = [expand(':p:h:h') . '/powerline/config_files'] 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