Merge branch 'feature/plugin-statuslines' into develop

Refs #3, #524, #470
Closes #377
Closes #451
This commit is contained in:
Kim Silkebækken 2013-08-20 17:29:02 +02:00
commit 44a37b0180
21 changed files with 352 additions and 35 deletions

View File

@ -1,36 +1,39 @@
{
"name": "Default color scheme",
"groups": {
"background": { "fg": "white", "bg": "gray2" },
"background:divider": { "fg": "gray6", "bg": "gray2" },
"mode": { "fg": "darkestgreen", "bg": "brightgreen", "attr": ["bold"] },
"visual_range": { "fg": "brightestorange", "bg": "darkorange", "attr": ["bold"] },
"modified_indicator": { "fg": "brightyellow", "bg": "gray4", "attr": ["bold"] },
"paste_indicator": { "fg": "white", "bg": "mediumorange", "attr": ["bold"] },
"readonly_indicator": { "fg": "brightestred", "bg": "gray4" },
"branch": { "fg": "gray9", "bg": "gray4" },
"branch_dirty": { "fg": "brightyellow", "bg": "gray4" },
"branch_clean": { "fg": "gray9", "bg": "gray4" },
"branch:divider": { "fg": "gray7", "bg": "gray4" },
"file_directory": { "fg": "gray9", "bg": "gray4" },
"file_name": { "fg": "white", "bg": "gray4", "attr": ["bold"] },
"file_size": { "fg": "gray8", "bg": "gray2" },
"file_name_no_file": { "fg": "gray9", "bg": "gray4", "attr": ["bold"] },
"file_name_empty": { "fg": "gray9", "bg": "gray4" },
"file_format": { "fg": "gray8", "bg": "gray2" },
"file_encoding": { "fg": "gray8", "bg": "gray2" },
"file_type": { "fg": "gray8", "bg": "gray2" },
"file_vcs_status": { "fg": "brightestred", "bg": "gray4" },
"file_vcs_status_M": { "fg": "brightyellow", "bg": "gray4" },
"file_vcs_status_A": { "fg": "brightgreen", "bg": "gray4" },
"line_percent": { "fg": "gray9", "bg": "gray4" },
"line_percent_gradient": { "fg": "green_yellow_red", "bg": "gray4" },
"line_current": { "fg": "gray1", "bg": "gray10", "attr": ["bold"] },
"line_current_symbol": { "fg": "gray1", "bg": "gray10" },
"background": { "fg": "white", "bg": "gray2" },
"background:divider": { "fg": "gray6", "bg": "gray2" },
"mode": { "fg": "darkestgreen", "bg": "brightgreen", "attr": ["bold"] },
"visual_range": { "fg": "brightestorange", "bg": "darkorange", "attr": ["bold"] },
"modified_indicator": { "fg": "brightyellow", "bg": "gray4", "attr": ["bold"] },
"paste_indicator": { "fg": "white", "bg": "mediumorange", "attr": ["bold"] },
"readonly_indicator": { "fg": "brightestred", "bg": "gray4" },
"branch": { "fg": "gray9", "bg": "gray4" },
"branch_dirty": { "fg": "brightyellow", "bg": "gray4" },
"branch_clean": { "fg": "gray9", "bg": "gray4" },
"branch:divider": { "fg": "gray7", "bg": "gray4" },
"file_directory": { "fg": "gray9", "bg": "gray4" },
"file_name": { "fg": "white", "bg": "gray4", "attr": ["bold"] },
"file_size": { "fg": "gray8", "bg": "gray2" },
"file_name_no_file": { "fg": "gray9", "bg": "gray4", "attr": ["bold"] },
"file_name_empty": { "fg": "gray9", "bg": "gray4" },
"file_format": { "fg": "gray8", "bg": "gray2" },
"file_encoding": { "fg": "gray8", "bg": "gray2" },
"file_type": { "fg": "gray8", "bg": "gray2" },
"file_vcs_status": { "fg": "brightestred", "bg": "gray4" },
"file_vcs_status_M": { "fg": "brightyellow", "bg": "gray4" },
"file_vcs_status_A": { "fg": "brightgreen", "bg": "gray4" },
"line_percent": { "fg": "gray9", "bg": "gray4" },
"line_percent_gradient": { "fg": "green_yellow_red", "bg": "gray4" },
"line_current": { "fg": "gray1", "bg": "gray10", "attr": ["bold"] },
"line_current_symbol": { "fg": "gray1", "bg": "gray10" },
"virtcol_current_gradient": { "fg": "dark_GREEN_Orange_red", "bg": "gray10" },
"col_current": { "fg": "gray6", "bg": "gray10" },
"modified_buffers": { "fg": "brightyellow", "bg": "gray2" },
"environment": { "fg": "gray8", "bg": "gray2" }
"col_current": { "fg": "gray6", "bg": "gray10" },
"modified_buffers": { "fg": "brightyellow", "bg": "gray2" },
"environment": { "fg": "gray8", "bg": "gray2" },
"error": { "fg": "brightestred", "bg": "darkred", "attr": ["bold"] },
"warning": { "fg": "brightyellow", "bg": "darkorange", "attr": ["bold"] },
"current_tag": { "fg": "gray9", "bg": "gray2" }
},
"mode_translations": {
"nc": {
@ -68,9 +71,9 @@
"green_yellow_red": "gray5"
},
"groups": {
"mode": { "fg": "darkestcyan", "bg": "white", "attr": ["bold"] },
"mode": { "fg": "darkestcyan", "bg": "white", "attr": ["bold"] },
"background:divider": { "fg": "darkcyan", "bg": "darkestblue" },
"branch:divider": { "fg": "darkcyan", "bg": "darkblue" }
"branch:divider": { "fg": "darkcyan", "bg": "darkblue" }
}
},
"v": {

View File

@ -29,7 +29,10 @@
"line_current_symbol": { "fg": "gray13", "bg": "lightyellow" },
"virtcol_current_gradient": { "fg": "GREEN_Orange_red", "bg": "gray10" },
"col_current": { "fg": "azure4", "bg": "lightyellow" },
"environment": { "fg": "gray61", "bg": "royalblue5" }
"environment": { "fg": "gray61", "bg": "royalblue5" },
"error": { "fg": "oldlace", "bg": "red", "attr": ["bold"] },
"warning": { "fg": "oldlace", "bg": "orange", "attr": ["bold"] }
"current_tag": { "fg": "oldlace", "bg": "royalblue5", "attr": ["bold"] }
},
"mode_translations": {
"nc": {

View File

@ -37,7 +37,12 @@
"local_themes": {
"cmdwin": "cmdwin",
"help": "help",
"quickfix": "quickfix"
"quickfix": "quickfix",
"powerline.matchers.plugin.nerdtree.nerdtree": "plugin/nerdtree",
"powerline.matchers.plugin.ctrlp.ctrlp": "plugin/ctrlp",
"powerline.matchers.plugin.gundo.gundo": "plugin/gundo",
"powerline.matchers.plugin.gundo.gundo_preview": "plugin/gundo-preview"
}
},
"wm": {

View File

@ -58,6 +58,19 @@
"name": "modified_indicator",
"before": " "
},
{
"exclude_modes": ["nc"],
"module": "powerline.segments.plugin.syntastic",
"name": "syntastic",
"priority": 50
},
{
"exclude_modes": ["nc"],
"module": "powerline.segments.plugin.tagbar",
"name": "current_tag",
"draw_soft_divider": false,
"priority": 50
},
{
"type": "string",
"highlight_group": ["background"],

View File

@ -0,0 +1,28 @@
{
"default_module": "powerline.segments.plugin.ctrlp",
"segments": {
"left": [
{
"name": "ctrlp",
"args": {
"side": "left"
}
},
{
"type": "string",
"highlight_group": ["ctrlp.background", "background"],
"draw_soft_divider": false,
"draw_hard_divider": false,
"width": "auto"
}
],
"right": [
{
"name": "ctrlp",
"args": {
"side": "right"
}
}
]
}
}

View File

@ -0,0 +1,19 @@
{
"default_module": "powerline.segments.plugin.gundo",
"segments": {
"left": [
{
"type": "string",
"highlight_group": ["gundo.name", "file_name"],
"contents": "Undo diff"
},
{
"type": "string",
"highlight_group": ["gundo.background", "background"],
"draw_soft_divider": false,
"draw_hard_divider": false,
"width": "auto"
}
]
}
}

View File

@ -0,0 +1,19 @@
{
"default_module": "powerline.segments.plugin.gundo",
"segments": {
"left": [
{
"type": "string",
"highlight_group": ["gundo.name", "file_name"],
"contents": "Undo tree"
},
{
"type": "string",
"highlight_group": ["gundo.background", "background"],
"draw_soft_divider": false,
"draw_hard_divider": false,
"width": "auto"
}
]
}
}

View File

@ -0,0 +1,17 @@
{
"default_module": "powerline.segments.plugin.nerdtree",
"segments": {
"left": [
{
"name": "nerdtree"
},
{
"type": "string",
"highlight_group": ["background"],
"draw_soft_divider": false,
"draw_hard_divider": false,
"width": "auto"
}
]
}
}

View File

@ -0,0 +1,2 @@
from pkgutil import extend_path
__path__ = extend_path(__path__, __name__)

View File

@ -0,0 +1,2 @@
from pkgutil import extend_path
__path__ = extend_path(__path__, __name__)

View File

@ -0,0 +1,21 @@
# vim:fileencoding=utf-8:noet
import os
import vim
vim.command('''function! Powerline_plugin_ctrlp_main(...)
let b:powerline_ctrlp_type = 'main'
let b:powerline_ctrlp_args = a:000
endfunction''')
vim.command('''function! Powerline_plugin_ctrlp_prog(...)
let b:powerline_ctrlp_type = 'prog'
let b:powerline_ctrlp_args = a:000
endfunction''')
vim.command('''let g:ctrlp_status_func = { 'main': 'Powerline_plugin_ctrlp_main', 'prog': 'Powerline_plugin_ctrlp_prog' }''')
def ctrlp(matcher_info):
name = matcher_info['buffer'].name
return name and os.path.basename(name) == 'ControlP'

View File

@ -0,0 +1,13 @@
# vim:fileencoding=utf-8:noet
import os
def gundo(matcher_info):
name = matcher_info['buffer'].name
return name and os.path.basename(name) == '__Gundo__'
def gundo_preview(matcher_info):
name = matcher_info['buffer'].name
return name and os.path.basename(name) == '__Gundo_Preview__'

View File

@ -0,0 +1,9 @@
# vim:fileencoding=utf-8:noet
import os
import re
def nerdtree(matcher_info):
name = matcher_info['buffer'].name
return name and re.match(r'NERD_tree_\d+', os.path.basename(name))

View File

@ -0,0 +1,2 @@
from pkgutil import extend_path
__path__ = extend_path(__path__, __name__)

View File

@ -0,0 +1,2 @@
from pkgutil import extend_path
__path__ = extend_path(__path__, __name__)

View File

@ -0,0 +1,89 @@
# vim:fileencoding=utf-8:noet
import vim
from powerline.bindings.vim import getbufvar
def ctrlp(pl, side):
ctrlp_type = getbufvar('%', 'powerline_ctrlp_type')
ctrlp_args = getbufvar('%', 'powerline_ctrlp_args')
return globals()['ctrlp_stl_{0}_{1}'.format(side, ctrlp_type)](pl, *ctrlp_args)
def ctrlp_stl_left_main(pl, focus, byfname, regex, prev, item, next, marked):
marked = marked[2:-1]
segments = []
if int(regex):
segments.append({
'contents': 'regex',
'highlight_group': ['ctrlp.regex', 'background'],
})
segments += [
{
'contents': prev + ' ',
'highlight_group': ['ctrlp.prev', 'background'],
'draw_inner_divider': True,
'priority': 40,
},
{
'contents': item,
'highlight_group': ['ctrlp.item', 'file_name'],
'draw_inner_divider': True,
'width': 10,
'align': 'c',
},
{
'contents': ' ' + next,
'highlight_group': ['ctrlp.next', 'background'],
'draw_inner_divider': True,
'priority': 40,
},
]
if marked != '-':
segments.append({
'contents': marked,
'highlight_group': ['ctrlp.marked', 'background'],
'draw_inner_divider': True,
})
return segments
def ctrlp_stl_right_main(pl, focus, byfname, regex, prev, item, next, marked):
segments = [
{
'contents': focus,
'highlight_group': ['ctrlp.focus', 'background'],
'draw_inner_divider': True,
'priority': 50,
},
{
'contents': byfname,
'highlight_group': ['ctrlp.byfname', 'background'],
'priority': 50,
},
]
return segments
def ctrlp_stl_left_prog(pl, progress):
return [
{
'contents': 'Loading...',
'highlight_group': ['ctrlp.progress', 'file_name'],
},
]
def ctrlp_stl_right_prog(pl, progress):
return [
{
'contents': progress,
'highlight_group': ['ctrlp.progress', 'file_name'],
},
]

View File

@ -0,0 +1,18 @@
# vim:fileencoding=utf-8:noet
import vim
from powerline.bindings.vim import getbufvar
from powerline.segments.vim import window_cached
@window_cached
def nerdtree(pl):
ntr = getbufvar('%', 'NERDTreeRoot')
if not ntr:
return
path_str = vim.eval('getbufvar("%", "NERDTreeRoot").path.str()')
return [{
'contents': path_str,
'highlight_group': ['nerdtree.path', 'file_name'],
}]

View File

@ -0,0 +1,28 @@
# vim:fileencoding=utf-8:noet
import vim
from powerline.segments.vim import window_cached
@window_cached
def syntastic(pl):
if not int(vim.eval('exists("g:SyntasticLoclist")')):
return
has_errors = int(vim.eval('g:SyntasticLoclist.current().hasErrorsOrWarningsToDisplay()'))
if not has_errors:
return
errors = vim.eval('g:SyntasticLoclist.current().errors()')
warnings = vim.eval('g:SyntasticLoclist.current().warnings()')
segments = []
if errors:
segments.append({
'contents': 'ERR:  {line} ({num}) '.format(line=errors[0]['lnum'], num=len(errors)),
'highlight_group': ['syntastic.error', 'error', 'background'],
})
if warnings:
segments.append({
'contents': 'WARN:  {line} ({num}) '.format(line=warnings[0]['lnum'], num=len(warnings)),
'highlight_group': ['syntastic.warning', 'warning', 'background'],
})
return segments

View File

@ -0,0 +1,12 @@
# vim:fileencoding=utf-8:noet
import vim
from powerline.segments.vim import window_cached
@window_cached
def current_tag(pl):
if not int(vim.eval('exists(":Tagbar")')):
return
return vim.eval('tagbar#currenttag("%s", "")')

View File

@ -19,9 +19,16 @@ class TestConfig(TestCase):
def test_vim(self):
from powerline.vim import VimPowerline
cfg_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'powerline', 'config_files')
buffers = ((('bufoptions',), {'buftype': 'help'}), (('bufname', '[Command Line]'), {}), (('bufoptions',), {'buftype': 'quickfix'}))
buffers = (
(('bufoptions',), {'buftype': 'help'}),
(('bufname', '[Command Line]'), {}),
(('bufoptions',), {'buftype': 'quickfix'}),
)
with open(os.path.join(cfg_path, 'config.json'), 'r') as f:
self.assertEqual(len(buffers), len(json.load(f)['ext']['vim']['local_themes']))
local_themes_raw = json.load(f)['ext']['vim']['local_themes']
# Don't run tests on external/plugin segments
local_themes = dict((k, v) for (k, v) in local_themes_raw.items() if not '.' in k)
self.assertEqual(len(buffers), len(local_themes))
outputs = {}
i = 0

View File

@ -156,6 +156,9 @@ def command(cmd):
elif cmd.startswith('hi '):
sp = cmd.split()
_highlights[sp[1]] = sp[2:]
elif cmd.startswith('function! Powerline_plugin_ctrlp'):
# Ignore CtrlP updating functions
pass
else:
raise NotImplementedError
@ -169,6 +172,8 @@ def eval(expr):
elif expr.startswith('PowerlineRegisterCachePurgerEvent'):
_buf_purge_events.add(expr[expr.find('"') + 1:expr.rfind('"') - 1])
return "0"
elif expr.startswith('exists('):
return '0'
raise NotImplementedError