diff --git a/powerline/ext/__init__.py b/powerline/bindings/__init__.py similarity index 100% rename from powerline/ext/__init__.py rename to powerline/bindings/__init__.py diff --git a/powerline/ext/vim/bindings.py b/powerline/bindings/vim/__init__.py similarity index 81% rename from powerline/ext/vim/bindings.py rename to powerline/bindings/vim/__init__.py index 6608372e..f96060dd 100644 --- a/powerline/ext/vim/bindings.py +++ b/powerline/bindings/vim/__init__.py @@ -2,6 +2,13 @@ import vim + +def source_plugin(): + import os + from powerline.bindings.vim import vim_get_func + fnameescape = vim_get_func('fnameescape') + vim.command('source ' + fnameescape(os.path.join(os.path.abspath(os.path.dirname(__file__)), 'powerline.vim'))) + try: _vim_globals = vim.bindeval('g:') diff --git a/powerline/ext/vim/powerline.vim b/powerline/bindings/vim/powerline.vim similarity index 100% rename from powerline/ext/vim/powerline.vim rename to powerline/bindings/vim/powerline.vim diff --git a/powerline/ext/vim/source_plugin.vim b/powerline/bindings/vim/source_plugin.vim similarity index 100% rename from powerline/ext/vim/source_plugin.vim rename to powerline/bindings/vim/source_plugin.vim diff --git a/powerline/core.py b/powerline/core.py index dec3c16a..844e4c73 100644 --- a/powerline/core.py +++ b/powerline/core.py @@ -6,8 +6,8 @@ import os import sys from colorscheme import Colorscheme -from segments import Segments -from matchers import Matchers +from segment import Segment +from matcher import Matcher class Powerline(object): @@ -30,8 +30,8 @@ class Powerline(object): # Load and initialize extension theme theme_config = self._load_theme_config(ext, self.config_ext.get('theme', 'default')) path = [os.path.expanduser(path) for path in self.config.get('paths', [])] - get_segment = Segments(ext, path, colorscheme, theme_config.get('default_module')).get - self.get_matcher = Matchers(ext, path).get + get_segment = Segment(ext, path, colorscheme, theme_config.get('default_module')).get + self.get_matcher = Matcher(ext, path).get theme_kwargs = { 'ext': ext, 'colorscheme': colorscheme, @@ -44,7 +44,7 @@ class Powerline(object): local_themes[key] = {'config': self._load_theme_config(ext, local_theme_name)} # Load and initialize extension renderer - renderer_module_name = 'powerline.ext.{0}.renderer'.format(ext) + renderer_module_name = 'powerline.renderers.{0}'.format(ext) renderer_class_name = '{0}Renderer'.format(ext.capitalize()) Renderer = getattr(importlib.import_module(renderer_module_name), renderer_class_name) self.renderer = Renderer(theme_config, local_themes, theme_kwargs) diff --git a/powerline/ext/terminal/__init__.py b/powerline/ext/terminal/__init__.py deleted file mode 100644 index 5bf82fe6..00000000 --- a/powerline/ext/terminal/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from renderer import TerminalRenderer # NOQA diff --git a/powerline/ext/tmux/__init__.py b/powerline/ext/tmux/__init__.py deleted file mode 100644 index c8e23c53..00000000 --- a/powerline/ext/tmux/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from renderer import TmuxRenderer # NOQA diff --git a/powerline/ext/vim/__init__.py b/powerline/ext/vim/__init__.py deleted file mode 100644 index a81ac37f..00000000 --- a/powerline/ext/vim/__init__.py +++ /dev/null @@ -1,9 +0,0 @@ -# -*- coding: utf-8 -*- - - -def source_plugin(): - import os - import vim - from bindings import vim_get_func - fnameescape = vim_get_func('fnameescape') - vim.command('source ' + fnameescape(os.path.join(os.path.abspath(os.path.dirname(__file__)), 'powerline.vim'))) diff --git a/powerline/matchers.py b/powerline/matcher.py similarity index 83% rename from powerline/matchers.py rename to powerline/matcher.py index c5f82e19..e61b5615 100644 --- a/powerline/matchers.py +++ b/powerline/matcher.py @@ -4,7 +4,7 @@ from importlib import import_module import sys -class Matchers(object): +class Matcher(object): def __init__(self, ext, path): self.ext = ext self.path = path @@ -12,7 +12,7 @@ class Matchers(object): def get(self, match_name): match_module, separator, match_function = match_name.rpartition('.') if not separator: - match_module = 'powerline.ext.{0}.matchers'.format(self.ext) + match_module = 'powerline.matchers.{0}'.format(self.ext) match_function = match_name oldpath = sys.path sys.path = self.path + sys.path diff --git a/powerline/ext/common/__init__.py b/powerline/matchers/__init__.py similarity index 100% rename from powerline/ext/common/__init__.py rename to powerline/matchers/__init__.py diff --git a/powerline/ext/vim/matchers.py b/powerline/matchers/vim.py similarity index 53% rename from powerline/ext/vim/matchers.py rename to powerline/matchers/vim.py index 4d11c9cd..fbaee480 100644 --- a/powerline/ext/vim/matchers.py +++ b/powerline/matchers/vim.py @@ -1,3 +1,7 @@ +# -*- coding: utf-8 -*- + +from __future__ import absolute_import + import vim diff --git a/powerline/renderers/__init__.py b/powerline/renderers/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/powerline/ext/terminal/renderer.py b/powerline/renderers/terminal.py similarity index 100% rename from powerline/ext/terminal/renderer.py rename to powerline/renderers/terminal.py diff --git a/powerline/ext/tmux/renderer.py b/powerline/renderers/tmux.py similarity index 100% rename from powerline/ext/tmux/renderer.py rename to powerline/renderers/tmux.py diff --git a/powerline/ext/vim/renderer.py b/powerline/renderers/vim.py similarity index 97% rename from powerline/ext/vim/renderer.py rename to powerline/renderers/vim.py index 7cc5f1bd..93997a21 100644 --- a/powerline/ext/vim/renderer.py +++ b/powerline/renderers/vim.py @@ -1,6 +1,8 @@ # -*- coding: utf-8 -*- -from powerline.ext.vim.bindings import vim_get_func +from __future__ import absolute_import + +from powerline.bindings.vim import vim_get_func from powerline.renderer import Renderer import vim diff --git a/powerline/segments.py b/powerline/segment.py similarity index 93% rename from powerline/segments.py rename to powerline/segment.py index e5245958..c6e50cce 100644 --- a/powerline/segments.py +++ b/powerline/segment.py @@ -4,9 +4,9 @@ from importlib import import_module import sys -class Segments(object): +class Segment(object): def __init__(self, ext, path, colorscheme, default_module=None): - self.default_module = default_module or 'powerline.ext.{0}.segments'.format(ext) + self.default_module = default_module or 'powerline.segments.{0}'.format(ext) self.path = path self.colorscheme = colorscheme diff --git a/powerline/segments/__init__.py b/powerline/segments/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/powerline/ext/common/segments.py b/powerline/segments/common.py similarity index 100% rename from powerline/ext/common/segments.py rename to powerline/segments/common.py diff --git a/powerline/ext/vim/segments.py b/powerline/segments/vim.py similarity index 97% rename from powerline/ext/vim/segments.py rename to powerline/segments/vim.py index 575fb9d6..09f8f068 100644 --- a/powerline/ext/vim/segments.py +++ b/powerline/segments/vim.py @@ -1,9 +1,11 @@ # -*- coding: utf-8 -*- +from __future__ import absolute_import + import os import vim -from powerline.ext.vim.bindings import vim_get_func +from powerline.bindings.vim import vim_get_func from powerline.lib import memoize from powerline.lib.vcs import guess diff --git a/powerline/themes/terminal/default.json b/powerline/themes/terminal/default.json index be399c6c..2b1720ad 100644 --- a/powerline/themes/terminal/default.json +++ b/powerline/themes/terminal/default.json @@ -1,5 +1,5 @@ { - "default_module": "powerline.ext.common.segments", + "default_module": "powerline.segments.common", "segments": { "left": [ { diff --git a/powerline/themes/tmux/default.json b/powerline/themes/tmux/default.json index 6197db10..77f726ae 100644 --- a/powerline/themes/tmux/default.json +++ b/powerline/themes/tmux/default.json @@ -1,5 +1,5 @@ { - "default_module": "powerline.ext.common.segments", + "default_module": "powerline.segments.common", "segments": { "left": [ {