Restructure extension directories

Refs #74.
This commit is contained in:
Kim Silkebækken 2013-01-19 18:09:20 +01:00
parent 65e358dee2
commit dfe5d5d829
21 changed files with 28 additions and 24 deletions

View File

@ -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:')

View File

@ -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)

View File

@ -1 +0,0 @@
from renderer import TerminalRenderer # NOQA

View File

@ -1 +0,0 @@
from renderer import TmuxRenderer # NOQA

View File

@ -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')))

View File

@ -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

View File

@ -1,3 +1,7 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
import vim

View File

View File

@ -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

View File

@ -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

View File

View File

@ -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

View File

@ -1,5 +1,5 @@
{
"default_module": "powerline.ext.common.segments",
"default_module": "powerline.segments.common",
"segments": {
"left": [
{

View File

@ -1,5 +1,5 @@
{
"default_module": "powerline.ext.common.segments",
"default_module": "powerline.segments.common",
"segments": {
"left": [
{