Merge pull request #1006 from ZyX-I/vim-reload-local_themes
Fix Vim extension reloading when using .add_local_theme()
This commit is contained in:
commit
14a68ef8f6
|
@ -394,7 +394,8 @@ class Powerline(object):
|
|||
self.prev_common_config = None
|
||||
self.prev_ext_config = None
|
||||
self.pl = None
|
||||
self.setup_args = None
|
||||
self.setup_args = ()
|
||||
self.setup_kwargs = {}
|
||||
self.imported_modules = set()
|
||||
|
||||
def create_renderer(self, load_main=False, load_colors=False, load_colorscheme=False, load_theme=False):
|
||||
|
@ -748,7 +749,8 @@ class Powerline(object):
|
|||
arguments for :py:meth:`reload` method and calls :py:meth:`do_setup`.
|
||||
'''
|
||||
self.shutdown_event.clear()
|
||||
self.setup_args = (args, kwargs)
|
||||
self.setup_args = args
|
||||
self.setup_kwargs.update(kwargs)
|
||||
self.do_setup(*args, **kwargs)
|
||||
|
||||
@staticmethod
|
||||
|
@ -787,8 +789,7 @@ class Powerline(object):
|
|||
self.shutdown(set_event=True)
|
||||
init_args, init_kwargs = self.init_args
|
||||
powerline = PowerlineClass(*init_args, **init_kwargs)
|
||||
setup_args, setup_kwargs = self.setup_args
|
||||
powerline.setup(*setup_args, **setup_kwargs)
|
||||
powerline.setup(*self.setup_args, **self.setup_kwargs)
|
||||
|
||||
def shutdown(self, set_event=True):
|
||||
'''Shut down all background threads.
|
||||
|
|
|
@ -49,7 +49,7 @@ class VimPowerline(Powerline):
|
|||
the same matcher already exists.
|
||||
'''
|
||||
self.update_renderer()
|
||||
key = self.get_matcher(key)
|
||||
matcher = self.get_matcher(key)
|
||||
theme_config = {}
|
||||
for cfg_path in self.theme_levels:
|
||||
try:
|
||||
|
@ -60,10 +60,15 @@ class VimPowerline(Powerline):
|
|||
mergedicts(theme_config, lvl_config)
|
||||
mergedicts(theme_config, config)
|
||||
try:
|
||||
self.renderer.add_local_theme(key, {'config': theme_config})
|
||||
self.renderer.add_local_theme(matcher, {'config': theme_config})
|
||||
except KeyError:
|
||||
return False
|
||||
else:
|
||||
# Hack for local themes support: when reloading modules it is not
|
||||
# guaranteed that .add_local_theme will be called once again, so
|
||||
# this function arguments will be saved here for calling from
|
||||
# .do_setup().
|
||||
self.setup_kwargs.setdefault('_local_themes', []).append((key, config))
|
||||
return True
|
||||
|
||||
def load_main_config(self):
|
||||
|
@ -110,7 +115,7 @@ class VimPowerline(Powerline):
|
|||
except KeyError:
|
||||
return super(VimPowerline, self).get_config_paths()
|
||||
|
||||
def do_setup(self, pyeval=None, pycmd=None, can_replace_pyeval=True):
|
||||
def do_setup(self, pyeval=None, pycmd=None, can_replace_pyeval=True, _local_themes=()):
|
||||
import __main__
|
||||
if not pyeval:
|
||||
pyeval = 'pyeval' if sys.version_info < (3,) else 'py3eval'
|
||||
|
@ -162,6 +167,10 @@ class VimPowerline(Powerline):
|
|||
vim.command(' autocmd! VimLeavePre * :{pycmd} powerline.shutdown()'.format(pycmd=pycmd))
|
||||
vim.command('augroup END')
|
||||
|
||||
# Hack for local themes support after reloading.
|
||||
for args in _local_themes:
|
||||
self.add_local_theme(*args)
|
||||
|
||||
@staticmethod
|
||||
def get_segment_info():
|
||||
return {}
|
||||
|
|
Loading…
Reference in New Issue