mirror of
https://github.com/powerline/powerline.git
synced 2025-07-21 21:05:11 +02:00
Add Control-P statuslines
This hacks around the way CtrlP handles statuslines. Powerline will always override the statusline, but CtrlP doesn't make its details available as buffer variables so separate functions assign the details to buffer variables each statusline redraw. Currently this statusline only uses a couple of highlight groups, colorschemes should add the HL groups to make this prettier.
This commit is contained in:
parent
2e38ab5686
commit
0b5b81774f
@ -39,7 +39,8 @@
|
||||
"help": "help",
|
||||
"quickfix": "quickfix",
|
||||
|
||||
"powerline.matchers.plugin.nerdtree.nerdtree": "plugin/nerdtree"
|
||||
"powerline.matchers.plugin.nerdtree.nerdtree": "plugin/nerdtree",
|
||||
"powerline.matchers.plugin.ctrlp.ctrlp": "plugin/ctrlp"
|
||||
}
|
||||
},
|
||||
"wm": {
|
||||
|
22
powerline/config_files/themes/vim/plugin/ctrlp.json
Normal file
22
powerline/config_files/themes/vim/plugin/ctrlp.json
Normal file
@ -0,0 +1,22 @@
|
||||
{
|
||||
"default_module": "powerline.segments.plugin.ctrlp",
|
||||
"segments": {
|
||||
"left": [
|
||||
{
|
||||
"name": "ctrlp_left"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"highlight_group": ["ctrlp.background", "background"],
|
||||
"draw_soft_divider": false,
|
||||
"draw_hard_divider": false,
|
||||
"width": "auto"
|
||||
}
|
||||
],
|
||||
"right": [
|
||||
{
|
||||
"name": "ctrlp_right"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
27
powerline/matchers/plugin/ctrlp.py
Normal file
27
powerline/matchers/plugin/ctrlp.py
Normal file
@ -0,0 +1,27 @@
|
||||
# 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'
|
94
powerline/segments/plugin/ctrlp.py
Normal file
94
powerline/segments/plugin/ctrlp.py
Normal file
@ -0,0 +1,94 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
|
||||
import vim
|
||||
|
||||
|
||||
def ctrlp_left(pl):
|
||||
ctrlp_type = vim.eval('getbufvar("%", "powerline_ctrlp_type")')
|
||||
ctrlp_args = vim.eval('getbufvar("%", "powerline_ctrlp_args")')
|
||||
|
||||
return globals()['ctrlp_stl_left_' + ctrlp_type](pl, *ctrlp_args)
|
||||
|
||||
|
||||
def ctrlp_right(pl):
|
||||
ctrlp_type = vim.eval('getbufvar("%", "powerline_ctrlp_type")')
|
||||
ctrlp_args = vim.eval('getbufvar("%", "powerline_ctrlp_args")')
|
||||
|
||||
return globals()['ctrlp_stl_right_' + 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,
|
||||
},
|
||||
{
|
||||
'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'],
|
||||
},
|
||||
]
|
Loading…
x
Reference in New Issue
Block a user