Move more vim stuff into the renderer
This commit is contained in:
parent
8960d15cf5
commit
04993264e4
|
@ -1,23 +0,0 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
from powerline.core import Powerline
|
|
||||||
from powerline.ext.vim.bindings import vim_get_func
|
|
||||||
|
|
||||||
vim_winwidth = vim_get_func('winwidth', rettype=int)
|
|
||||||
vim_getwinvar = vim_get_func('getwinvar')
|
|
||||||
vim_setwinvar = vim_get_func('setwinvar')
|
|
||||||
|
|
||||||
pl = Powerline('vim')
|
|
||||||
|
|
||||||
|
|
||||||
def statusline(winnr):
|
|
||||||
current = vim_getwinvar(winnr, 'current')
|
|
||||||
winwidth = vim_winwidth(winnr)
|
|
||||||
|
|
||||||
mode = vim_get_func('mode')()
|
|
||||||
if not current:
|
|
||||||
mode = 'nc'
|
|
||||||
|
|
||||||
statusline = pl.renderer.render(mode, winwidth)
|
|
||||||
|
|
||||||
return statusline
|
|
|
@ -4,6 +4,8 @@
|
||||||
python import sys, vim, os
|
python import sys, vim, os
|
||||||
python sys.path.append(vim.eval('expand("<sfile>:h:h:h")'))
|
python sys.path.append(vim.eval('expand("<sfile>:h:h:h")'))
|
||||||
python from examples.vim.pl import statusline
|
python from examples.vim.pl import statusline
|
||||||
|
python from powerline.core import Powerline
|
||||||
|
python pl = Powerline('vim')
|
||||||
|
|
||||||
if exists('*pyeval')
|
if exists('*pyeval')
|
||||||
let s:pyeval = function('pyeval')
|
let s:pyeval = function('pyeval')
|
||||||
|
@ -15,7 +17,7 @@ else
|
||||||
endif
|
endif
|
||||||
|
|
||||||
function! Powerline(winnr)
|
function! Powerline(winnr)
|
||||||
return s:pyeval('statusline('. a:winnr .')')
|
return s:pyeval('pl.renderer.render('. a:winnr .')')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:WinDoPowerline()
|
function! s:WinDoPowerline()
|
||||||
|
|
|
@ -1,9 +1,15 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from powerline.ext.vim.bindings import vim_get_func
|
||||||
from powerline.renderer import Renderer
|
from powerline.renderer import Renderer
|
||||||
|
|
||||||
import vim
|
import vim
|
||||||
|
|
||||||
|
vim_mode = vim_get_func('mode')
|
||||||
|
vim_winwidth = vim_get_func('winwidth', rettype=int)
|
||||||
|
vim_getwinvar = vim_get_func('getwinvar')
|
||||||
|
vim_setwinvar = vim_get_func('setwinvar')
|
||||||
|
|
||||||
|
|
||||||
class VimRenderer(Renderer):
|
class VimRenderer(Renderer):
|
||||||
'''Powerline vim segment renderer.
|
'''Powerline vim segment renderer.
|
||||||
|
@ -14,9 +20,17 @@ class VimRenderer(Renderer):
|
||||||
super(VimRenderer, self).__init__(theme)
|
super(VimRenderer, self).__init__(theme)
|
||||||
self.hl_groups = {}
|
self.hl_groups = {}
|
||||||
|
|
||||||
def render(self, mode, width=None):
|
def render(self, winnr):
|
||||||
statusline = super(VimRenderer, self).render(mode, width)
|
current = vim_getwinvar(winnr, 'current')
|
||||||
|
winwidth = vim_winwidth(winnr)
|
||||||
|
|
||||||
|
mode = vim_mode()
|
||||||
|
if not current:
|
||||||
|
mode = 'nc'
|
||||||
|
|
||||||
|
statusline = super(VimRenderer, self).render(mode, winwidth)
|
||||||
statusline = statusline.replace(self.PERCENT_PLACEHOLDER, '%%')
|
statusline = statusline.replace(self.PERCENT_PLACEHOLDER, '%%')
|
||||||
|
|
||||||
return statusline
|
return statusline
|
||||||
|
|
||||||
def hl(self, fg=None, bg=None, attr=None):
|
def hl(self, fg=None, bg=None, attr=None):
|
||||||
|
|
Loading…
Reference in New Issue