Merge 9af71dfb4b
into 574bb1887b
This commit is contained in:
commit
e076b4fefa
|
@ -46,6 +46,13 @@
|
|||
"commandt:label": "file_name",
|
||||
"commandt:background": "background",
|
||||
"commandt:finder": "file_name",
|
||||
"commandt:path": "file_directory"
|
||||
"commandt:path": "file_directory",
|
||||
|
||||
"ctrlp:label": "file_name",
|
||||
"ctrlp:background": "background",
|
||||
"ctrlp:status": "background",
|
||||
"ctrlp:status_other": "file_name",
|
||||
"ctrlp:marked": "file_name",
|
||||
"ctrlp:prog": "file_name"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,7 +41,8 @@
|
|||
"powerline.matchers.vim.plugin.nerdtree.nerdtree": "plugin_nerdtree",
|
||||
"powerline.matchers.vim.plugin.commandt.commandt": "plugin_commandt",
|
||||
"powerline.matchers.vim.plugin.gundo.gundo": "plugin_gundo",
|
||||
"powerline.matchers.vim.plugin.gundo.gundo_preview": "plugin_gundo-preview"
|
||||
"powerline.matchers.vim.plugin.gundo.gundo_preview": "plugin_gundo-preview",
|
||||
"powerline.matchers.vim.plugin.ctrlp.ctrlp": "plugin_ctrlp"
|
||||
}
|
||||
},
|
||||
"wm": {
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
{
|
||||
"segments": {
|
||||
"left": [
|
||||
{
|
||||
"type": "string",
|
||||
"contents": "ControlP",
|
||||
"highlight_groups": ["ctrlp:label"]
|
||||
},
|
||||
{
|
||||
"function": "powerline.segments.vim.plugin.ctrlp.mode_prev",
|
||||
"draw_soft_divider": false,
|
||||
"draw_hard_divider": false
|
||||
},
|
||||
{
|
||||
"function": "powerline.segments.vim.plugin.ctrlp.mode",
|
||||
"draw_soft_divider": false,
|
||||
"draw_hard_divider": false
|
||||
},
|
||||
{
|
||||
"function": "powerline.segments.vim.plugin.ctrlp.mode_next",
|
||||
"draw_soft_divider": false,
|
||||
"draw_hard_divider": false
|
||||
},
|
||||
{
|
||||
"function": "powerline.segments.vim.plugin.ctrlp.marked",
|
||||
"draw_soft_divider": false,
|
||||
"draw_hard_divider": false
|
||||
},
|
||||
{
|
||||
"function": "powerline.segments.vim.plugin.ctrlp.prog"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"highlight_groups": ["ctrlp:background"],
|
||||
"draw_soft_divider": false,
|
||||
"draw_hard_divider": false,
|
||||
"width": "auto"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
import os
|
||||
|
||||
from powerline.bindings.vim import buffer_name
|
||||
|
||||
|
||||
def ctrlp(matcher_info):
|
||||
name = buffer_name(matcher_info)
|
||||
return name and os.path.basename(name) == b'ControlP'
|
|
@ -0,0 +1,123 @@
|
|||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
try:
|
||||
import vim
|
||||
except ImportError:
|
||||
vim = object()
|
||||
|
||||
from powerline.bindings.vim import vim_getvar
|
||||
|
||||
|
||||
initialized = False
|
||||
|
||||
|
||||
def initialize(pl, shutdown_event):
|
||||
global initialized
|
||||
if initialized:
|
||||
return
|
||||
initialized = True
|
||||
vim.command(
|
||||
'''
|
||||
function! Ctrlp_status_main(focus, byfname, regex, prev, item, next, marked)
|
||||
let g:_powerline_ctrlp_status = {\
|
||||
'focus': a:focus,\
|
||||
'byfname': a:byfname,\
|
||||
'regex': a:regex,\
|
||||
'prev': a:prev,\
|
||||
'item': a:item,\
|
||||
'next': a:next,\
|
||||
'marked': a:marked,\
|
||||
}
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
function! Ctrlp_status_prog(str)
|
||||
let g:_powerline_ctrlp_status.prog = a:str
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
let g:ctrlp_status_func = {\
|
||||
'main': 'Ctrlp_status_main',\
|
||||
'prog': 'Ctrlp_status_prog',\
|
||||
}
|
||||
|
||||
call ctrlp#call('s:opts')
|
||||
call ctrlp#statusline()
|
||||
'''
|
||||
)
|
||||
|
||||
|
||||
def marked(pl):
|
||||
'''Returns boolean indicating whether anything is marked or not.
|
||||
|
||||
Highlight groups used: ``ctrlp:marked``.
|
||||
'''
|
||||
status = vim_getvar('_powerline_ctrlp_status')
|
||||
if 'prog' in status or 'marked' not in status or status['marked'] == ' <->':
|
||||
return None
|
||||
return [{
|
||||
'highlight_groups': ['ctrlp:marked'],
|
||||
'contents': status['marked'].strip()
|
||||
}]
|
||||
marked.startup = initialize
|
||||
|
||||
|
||||
def mode(pl):
|
||||
'''Returns current mode.
|
||||
|
||||
Highlight groups used: ``ctrlp:status``.
|
||||
'''
|
||||
status = vim_getvar('_powerline_ctrlp_status')
|
||||
if 'prog' in status or 'item' not in status:
|
||||
return None
|
||||
return [{
|
||||
'highlight_groups': ['ctrlp:status'],
|
||||
'contents': ' ' + status['item'] + ' '
|
||||
}]
|
||||
mode.startup = initialize
|
||||
|
||||
|
||||
def mode_prev(pl):
|
||||
'''Returns previous mode.
|
||||
|
||||
Highlight groups used: ``ctrlp:status_other``.
|
||||
'''
|
||||
status = vim_getvar('_powerline_ctrlp_status')
|
||||
if 'prog' in status or 'prev' not in status:
|
||||
return None
|
||||
return [{
|
||||
'highlight_groups': ['ctrlp:status_other'],
|
||||
'contents': status['prev'] + ' '
|
||||
}]
|
||||
mode_prev.startup = initialize
|
||||
|
||||
|
||||
def mode_next(pl):
|
||||
'''Returns next mode.
|
||||
|
||||
Highlight groups used: ``ctrlp:status_other``.
|
||||
'''
|
||||
status = vim_getvar('_powerline_ctrlp_status')
|
||||
if 'prog' in status or 'next' not in status:
|
||||
return None
|
||||
return [{
|
||||
'highlight_groups': ['ctrlp:status_other'],
|
||||
'contents': ' ' + status['next'] + ' '
|
||||
}]
|
||||
mode_next.startup = initialize
|
||||
|
||||
|
||||
def prog(pl):
|
||||
'''Returns progress status.
|
||||
|
||||
Highlight groups used: ``ctrlp:prog``.
|
||||
'''
|
||||
status = vim_getvar('_powerline_ctrlp_status')
|
||||
if 'prog' not in status:
|
||||
return None
|
||||
return [{
|
||||
'highlight_groups': ['ctrlp:prog'],
|
||||
'contents': status['prog']
|
||||
}]
|
||||
prog.startup = initialize
|
|
@ -54,6 +54,7 @@ class TestVimConfig(TestCase):
|
|||
(('bufname', 'NERD_tree_1'), {}),
|
||||
(('bufname', '__Gundo__'), {}),
|
||||
(('bufname', '__Gundo_Preview__'), {}),
|
||||
# No CtrlP tests here: requires emulation
|
||||
# No Command-T tests here: requires +ruby or emulation
|
||||
# No tabline here: tablines are tested separately
|
||||
)
|
||||
|
@ -61,8 +62,8 @@ class TestVimConfig(TestCase):
|
|||
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())
|
||||
# See end of the buffers definition above for `- 2`
|
||||
self.assertEqual(len(buffers), len(local_themes) - 2)
|
||||
# See end of the buffers definition above for `- 3`
|
||||
self.assertEqual(len(buffers), len(local_themes) - 3)
|
||||
outputs = {}
|
||||
i = 0
|
||||
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
#!/usr/bin/vim -S
|
||||
set nocompatible
|
||||
set columns=80
|
||||
execute 'source' fnameescape(expand('<sfile>:p:h:h').'/vim_utils.vim')
|
||||
call EnablePlugins('ctrlp.vim')
|
||||
call SourcePowerline()
|
||||
let g:statusline_values = []
|
||||
call PyFile('setup_statusline_catcher')
|
||||
execute 'CtrlPBuffer'
|
||||
call RunPython('powerline.render = _powerline_old_render')
|
||||
let g:expected_statusline = '%#Pl_231_16777215_240_5789784_bold# ControlP %#Pl_231_16777215_240_5789784_NONE# %#Pl_231_16777215_240_5789784_bold#fil %#Pl_231_16777215_236_3158064_NONE# buffers %#Pl_231_16777215_240_5789784_bold# mru %#Pl_231_16777215_236_3158064_NONE# '
|
||||
call CheckMessages()
|
||||
if index(g:statusline_values, g:expected_statusline) == -1
|
||||
call CheckStatuslineValue(get(g:statusline_values, -1, ''), g:expected_statusline)
|
||||
cquit
|
||||
endif
|
||||
qall
|
Loading…
Reference in New Issue