mirror of
https://github.com/powerline/powerline.git
synced 2025-07-31 01:35:40 +02:00
Merge 9af71dfb4b8771ad51c447c88a13e8c0617cb981 into 574bb1887b9f27b3c046c6b74a1f3ed75b115a75
This commit is contained in:
commit
e076b4fefa
@ -46,6 +46,13 @@
|
|||||||
"commandt:label": "file_name",
|
"commandt:label": "file_name",
|
||||||
"commandt:background": "background",
|
"commandt:background": "background",
|
||||||
"commandt:finder": "file_name",
|
"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.nerdtree.nerdtree": "plugin_nerdtree",
|
||||||
"powerline.matchers.vim.plugin.commandt.commandt": "plugin_commandt",
|
"powerline.matchers.vim.plugin.commandt.commandt": "plugin_commandt",
|
||||||
"powerline.matchers.vim.plugin.gundo.gundo": "plugin_gundo",
|
"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": {
|
"wm": {
|
||||||
|
41
powerline/config_files/themes/vim/plugin_ctrlp.json
Normal file
41
powerline/config_files/themes/vim/plugin_ctrlp.json
Normal file
@ -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"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
11
powerline/matchers/vim/plugin/ctrlp.py
Normal file
11
powerline/matchers/vim/plugin/ctrlp.py
Normal file
@ -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'
|
123
powerline/segments/vim/plugin/ctrlp.py
Normal file
123
powerline/segments/vim/plugin/ctrlp.py
Normal file
@ -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', 'NERD_tree_1'), {}),
|
||||||
(('bufname', '__Gundo__'), {}),
|
(('bufname', '__Gundo__'), {}),
|
||||||
(('bufname', '__Gundo_Preview__'), {}),
|
(('bufname', '__Gundo_Preview__'), {}),
|
||||||
|
# No CtrlP tests here: requires emulation
|
||||||
# No Command-T tests here: requires +ruby or emulation
|
# No Command-T tests here: requires +ruby or emulation
|
||||||
# No tabline here: tablines are tested separately
|
# No tabline here: tablines are tested separately
|
||||||
)
|
)
|
||||||
@ -61,8 +62,8 @@ class TestVimConfig(TestCase):
|
|||||||
local_themes_raw = 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
|
# Don’t run tests on external/plugin segments
|
||||||
local_themes = dict((k, v) for (k, v) in local_themes_raw.items())
|
local_themes = dict((k, v) for (k, v) in local_themes_raw.items())
|
||||||
# See end of the buffers definition above for `- 2`
|
# See end of the buffers definition above for `- 3`
|
||||||
self.assertEqual(len(buffers), len(local_themes) - 2)
|
self.assertEqual(len(buffers), len(local_themes) - 3)
|
||||||
outputs = {}
|
outputs = {}
|
||||||
i = 0
|
i = 0
|
||||||
|
|
||||||
|
17
tests/test_vim/tests/ctrlp_plugin.vim
Executable file
17
tests/test_vim/tests/ctrlp_plugin.vim
Executable file
@ -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…
x
Reference in New Issue
Block a user