Ignore highlight definitions for function segments
Also removed divider_highlight_group from configuration: it is actually used only in function segments. Fixes #215
This commit is contained in:
parent
045d60fbc4
commit
f319ddc33b
|
@ -90,7 +90,6 @@ segments that you may want to customize right away:
|
||||||
{
|
{
|
||||||
"name": "weather",
|
"name": "weather",
|
||||||
"priority": 50,
|
"priority": 50,
|
||||||
"divider_highlight_group": "background:divider"
|
|
||||||
"args": {
|
"args": {
|
||||||
"unit": "f",
|
"unit": "f",
|
||||||
"location_query": "oslo, norway"
|
"location_query": "oslo, norway"
|
||||||
|
@ -289,6 +288,8 @@ Themes
|
||||||
of highlighting groups, where the first highlighting group that is
|
of highlighting groups, where the first highlighting group that is
|
||||||
available in the colorscheme is used.
|
available in the colorscheme is used.
|
||||||
|
|
||||||
|
Ignored for segments that have ``function`` type.
|
||||||
|
|
||||||
``before``
|
``before``
|
||||||
.. _config-themes-seg-before:
|
.. _config-themes-seg-before:
|
||||||
|
|
||||||
|
|
|
@ -29,8 +29,7 @@
|
||||||
"name": "cwd",
|
"name": "cwd",
|
||||||
"args": {
|
"args": {
|
||||||
"dir_limit_depth": 3
|
"dir_limit_depth": 3
|
||||||
},
|
}
|
||||||
"divider_highlight_group": "cwd:divider"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"right": [
|
"right": [
|
||||||
|
|
|
@ -32,8 +32,7 @@
|
||||||
"name": "cwd",
|
"name": "cwd",
|
||||||
"args": {
|
"args": {
|
||||||
"dir_limit_depth": 3
|
"dir_limit_depth": 3
|
||||||
},
|
}
|
||||||
"divider_highlight_group": "cwd:divider"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "last_status",
|
"name": "last_status",
|
||||||
|
|
|
@ -22,37 +22,33 @@
|
||||||
"right": [
|
"right": [
|
||||||
{
|
{
|
||||||
"name": "uptime",
|
"name": "uptime",
|
||||||
"priority": 50,
|
"priority": 50
|
||||||
"divider_highlight_group": "background:divider"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "external_ip",
|
"name": "external_ip",
|
||||||
"priority": 50,
|
"priority": 50
|
||||||
"divider_highlight_group": "background:divider"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "network_load",
|
"name": "network_load",
|
||||||
"priority": 50,
|
"priority": 50
|
||||||
"divider_highlight_group": "background:divider"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "system_load",
|
"name": "system_load",
|
||||||
"priority": 50,
|
"priority": 50
|
||||||
"divider_highlight_group": "background:divider"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "weather",
|
"name": "weather",
|
||||||
"priority": 50,
|
"priority": 50
|
||||||
"divider_highlight_group": "background:divider"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "date"
|
"name": "date"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "date",
|
"name": "date",
|
||||||
"args": {"format": "%H:%M"},
|
"args": {
|
||||||
"highlight_group": ["time", "date"],
|
"format": "%H:%M",
|
||||||
"divider_highlight_group": "time:divider"
|
"istime": true
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "email_imap_alert",
|
"name": "email_imap_alert",
|
||||||
|
|
|
@ -28,8 +28,7 @@
|
||||||
{
|
{
|
||||||
"name": "branch",
|
"name": "branch",
|
||||||
"exclude_modes": ["nc"],
|
"exclude_modes": ["nc"],
|
||||||
"priority": 60,
|
"priority": 60
|
||||||
"divider_highlight_group": "branch:divider"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "readonly_indicator",
|
"name": "readonly_indicator",
|
||||||
|
@ -66,20 +65,17 @@
|
||||||
"name": "file_format",
|
"name": "file_format",
|
||||||
"draw_divider": false,
|
"draw_divider": false,
|
||||||
"exclude_modes": ["nc"],
|
"exclude_modes": ["nc"],
|
||||||
"priority": 50,
|
"priority": 50
|
||||||
"divider_highlight_group": "background:divider"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "file_encoding",
|
"name": "file_encoding",
|
||||||
"exclude_modes": ["nc"],
|
"exclude_modes": ["nc"],
|
||||||
"priority": 50,
|
"priority": 50
|
||||||
"divider_highlight_group": "background:divider"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "file_type",
|
"name": "file_type",
|
||||||
"exclude_modes": ["nc"],
|
"exclude_modes": ["nc"],
|
||||||
"priority": 50,
|
"priority": 50
|
||||||
"divider_highlight_group": "background:divider"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "line_percent",
|
"name": "line_percent",
|
||||||
|
|
|
@ -4,18 +4,18 @@
|
||||||
"right": [
|
"right": [
|
||||||
{
|
{
|
||||||
"name": "weather",
|
"name": "weather",
|
||||||
"priority": 50,
|
"priority": 50
|
||||||
"divider_highlight_group": "background:divider"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "date"
|
"name": "date"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "date",
|
"name": "date",
|
||||||
"args": {"format": "%H:%M"},
|
"args": {
|
||||||
"before": "⌚ ",
|
"format": "%H:%M",
|
||||||
"highlight_group": ["time", "date"],
|
"istime": true
|
||||||
"divider_highlight_group": "time:divider"
|
},
|
||||||
|
"before": "⌚ "
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "email_imap_alert",
|
"name": "email_imap_alert",
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
from functools import wraps
|
||||||
|
|
||||||
from powerline.lib.memoize import memoize # NOQA
|
from powerline.lib.memoize import memoize # NOQA
|
||||||
from powerline.lib.humanize_bytes import humanize_bytes # NOQA
|
from powerline.lib.humanize_bytes import humanize_bytes # NOQA
|
||||||
from powerline.lib.url import urllib_read, urllib_urlencode # NOQA
|
from powerline.lib.url import urllib_read, urllib_urlencode # NOQA
|
||||||
|
@ -16,3 +18,19 @@ def mergedicts(d1, d2):
|
||||||
mergedicts(d1[k], d2[k])
|
mergedicts(d1[k], d2[k])
|
||||||
else:
|
else:
|
||||||
d1[k] = d2[k]
|
d1[k] = d2[k]
|
||||||
|
|
||||||
|
|
||||||
|
def add_divider_highlight_group(highlight_group):
|
||||||
|
def dec(func):
|
||||||
|
@wraps(func)
|
||||||
|
def f(**kwargs):
|
||||||
|
r = func(**kwargs)
|
||||||
|
if r:
|
||||||
|
return [{
|
||||||
|
'contents': r,
|
||||||
|
'divider_highlight_group': highlight_group,
|
||||||
|
}]
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
return f
|
||||||
|
return dec
|
||||||
|
|
|
@ -30,7 +30,7 @@ class Renderer(object):
|
||||||
def get_highlighting(self, segment, mode):
|
def get_highlighting(self, segment, mode):
|
||||||
segment['highlight'] = self.colorscheme.get_highlighting(segment['highlight_group'], mode, segment.get('gradient_level'))
|
segment['highlight'] = self.colorscheme.get_highlighting(segment['highlight_group'], mode, segment.get('gradient_level'))
|
||||||
if segment['divider_highlight_group']:
|
if segment['divider_highlight_group']:
|
||||||
segment['divider_highlight'] = self.colorscheme.get_highlighting(segment['divider_highlight_group'], mode)
|
segment['divider_highlight'] = self.colorscheme.get_highlighting([segment['divider_highlight_group']], mode)
|
||||||
else:
|
else:
|
||||||
segment['divider_highlight'] = None
|
segment['divider_highlight'] = None
|
||||||
return segment
|
return segment
|
||||||
|
|
|
@ -66,12 +66,11 @@ def gen_segment_getter(ext, path, theme_configs, default_module=None):
|
||||||
except KeyError:
|
except KeyError:
|
||||||
raise TypeError('Unknown segment type: {0}'.format(segment_type))
|
raise TypeError('Unknown segment type: {0}'.format(segment_type))
|
||||||
contents, contents_func, module = get_segment_info(data, segment)
|
contents, contents_func, module = get_segment_info(data, segment)
|
||||||
highlight_group = segment.get('highlight_group', segment.get('name'))
|
highlight_group = segment_type != 'function' and segment.get('highlight_group') or segment.get('name')
|
||||||
divider_highlight_group = segment.get('divider_highlight_group')
|
|
||||||
return {
|
return {
|
||||||
'type': segment_type,
|
'type': segment_type,
|
||||||
'highlight_group': scalar_to_list(highlight_group),
|
'highlight_group': scalar_to_list(highlight_group),
|
||||||
'divider_highlight_group': scalar_to_list(divider_highlight_group) if divider_highlight_group else None,
|
'divider_highlight_group': None,
|
||||||
'before': get_key(segment, module, 'before', ''),
|
'before': get_key(segment, module, 'before', ''),
|
||||||
'after': get_key(segment, module, 'after', ''),
|
'after': get_key(segment, module, 'after', ''),
|
||||||
'contents_func': contents_func,
|
'contents_func': contents_func,
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from powerline.lib import memoize, urllib_read, urllib_urlencode
|
from powerline.lib import memoize, urllib_read, urllib_urlencode, add_divider_highlight_group
|
||||||
|
from functools import wraps
|
||||||
|
|
||||||
|
|
||||||
def hostname(only_if_ssh=False):
|
def hostname(only_if_ssh=False):
|
||||||
|
@ -80,19 +81,24 @@ def cwd(dir_shorten_len=None, dir_limit_depth=None):
|
||||||
continue
|
continue
|
||||||
ret.append({
|
ret.append({
|
||||||
'contents': part,
|
'contents': part,
|
||||||
|
'divider_highlight_group': 'cwd:divider',
|
||||||
})
|
})
|
||||||
ret[-1]['highlight_group'] = ['cwd:current_folder', 'cwd']
|
ret[-1]['highlight_group'] = ['cwd:current_folder', 'cwd']
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
def date(format='%Y-%m-%d'):
|
def date(format='%Y-%m-%d', istime=False):
|
||||||
'''Return the current date.
|
'''Return the current date.
|
||||||
|
|
||||||
:param str format:
|
:param str format:
|
||||||
strftime-style date format string
|
strftime-style date format string
|
||||||
'''
|
'''
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
return datetime.now().strftime(format)
|
return [{
|
||||||
|
'contents': datetime.now().strftime(format),
|
||||||
|
'highlight_group': (['time'] if istime else []) + ['date'],
|
||||||
|
'divider_highlight_group': 'time:divider' if istime else None,
|
||||||
|
}]
|
||||||
|
|
||||||
|
|
||||||
def fuzzy_time():
|
def fuzzy_time():
|
||||||
|
@ -148,6 +154,7 @@ def fuzzy_time():
|
||||||
|
|
||||||
|
|
||||||
@memoize(600)
|
@memoize(600)
|
||||||
|
@add_divider_highlight_group('background:divider')
|
||||||
def external_ip(query_url='http://ipv4.icanhazip.com/'):
|
def external_ip(query_url='http://ipv4.icanhazip.com/'):
|
||||||
'''Return external IP address.
|
'''Return external IP address.
|
||||||
|
|
||||||
|
@ -163,6 +170,7 @@ def external_ip(query_url='http://ipv4.icanhazip.com/'):
|
||||||
return urllib_read(query_url).strip()
|
return urllib_read(query_url).strip()
|
||||||
|
|
||||||
|
|
||||||
|
@add_divider_highlight_group('background:divider')
|
||||||
def uptime(format='{days:02d}d {hours:02d}h {minutes:02d}m'):
|
def uptime(format='{days:02d}d {hours:02d}h {minutes:02d}m'):
|
||||||
'''Return system uptime.
|
'''Return system uptime.
|
||||||
|
|
||||||
|
@ -265,6 +273,7 @@ weather_conditions_icons = {
|
||||||
|
|
||||||
|
|
||||||
@memoize(1800)
|
@memoize(1800)
|
||||||
|
@add_divider_highlight_group('background:divider')
|
||||||
def weather(unit='c', location_query=None, icons=None):
|
def weather(unit='c', location_query=None, icons=None):
|
||||||
'''Return weather from Yahoo! Weather.
|
'''Return weather from Yahoo! Weather.
|
||||||
|
|
||||||
|
@ -360,6 +369,7 @@ def system_load(format='{avg:.1f}', threshold_good=1, threshold_bad=2):
|
||||||
'contents': format.format(avg=avg),
|
'contents': format.format(avg=avg),
|
||||||
'highlight_group': [hl, 'system_load'],
|
'highlight_group': [hl, 'system_load'],
|
||||||
'draw_divider': False,
|
'draw_divider': False,
|
||||||
|
'divider_highlight_group': 'background:divider',
|
||||||
})
|
})
|
||||||
ret[0]['draw_divider'] = True
|
ret[0]['draw_divider'] = True
|
||||||
ret[0]['contents'] += ' '
|
ret[0]['contents'] += ' '
|
||||||
|
@ -383,6 +393,7 @@ def cpu_load_percent(measure_interval=.5):
|
||||||
return u'{0}%'.format(cpu_percent)
|
return u'{0}%'.format(cpu_percent)
|
||||||
|
|
||||||
|
|
||||||
|
@add_divider_highlight_group('background:divider')
|
||||||
def network_load(interface='eth0', measure_interval=1, suffix='B/s', binary_prefix=False):
|
def network_load(interface='eth0', measure_interval=1, suffix='B/s', binary_prefix=False):
|
||||||
'''Return the network load.
|
'''Return the network load.
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ except ImportError:
|
||||||
|
|
||||||
from powerline.bindings.vim import vim_get_func, getbufvar
|
from powerline.bindings.vim import vim_get_func, getbufvar
|
||||||
from powerline.theme import requires_segment_info
|
from powerline.theme import requires_segment_info
|
||||||
from powerline.lib import memoize, humanize_bytes
|
from powerline.lib import memoize, humanize_bytes, add_divider_highlight_group
|
||||||
from powerline.lib.vcs import guess
|
from powerline.lib.vcs import guess
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
|
||||||
|
@ -201,6 +201,7 @@ def file_size(segment_info, suffix='B', binary_prefix=False):
|
||||||
|
|
||||||
|
|
||||||
@requires_segment_info
|
@requires_segment_info
|
||||||
|
@add_divider_highlight_group('background:divider')
|
||||||
def file_format(segment_info):
|
def file_format(segment_info):
|
||||||
'''Return file format (i.e. line ending type).
|
'''Return file format (i.e. line ending type).
|
||||||
|
|
||||||
|
@ -210,6 +211,7 @@ def file_format(segment_info):
|
||||||
|
|
||||||
|
|
||||||
@requires_segment_info
|
@requires_segment_info
|
||||||
|
@add_divider_highlight_group('background:divider')
|
||||||
def file_encoding(segment_info):
|
def file_encoding(segment_info):
|
||||||
'''Return file encoding/character set.
|
'''Return file encoding/character set.
|
||||||
|
|
||||||
|
@ -219,6 +221,7 @@ def file_encoding(segment_info):
|
||||||
|
|
||||||
|
|
||||||
@requires_segment_info
|
@requires_segment_info
|
||||||
|
@add_divider_highlight_group('background:divider')
|
||||||
def file_type(segment_info):
|
def file_type(segment_info):
|
||||||
'''Return file type.
|
'''Return file type.
|
||||||
|
|
||||||
|
@ -262,7 +265,9 @@ def col_current(segment_info):
|
||||||
@window_cached
|
@window_cached
|
||||||
def virtcol_current():
|
def virtcol_current():
|
||||||
'''Return current visual column with concealed characters ingored'''
|
'''Return current visual column with concealed characters ingored'''
|
||||||
return vim_funcs['virtcol']('.')
|
return [{'contents': vim_funcs['virtcol']('.'),
|
||||||
|
'highlight_group': ['virtcol_current', 'col_current'],
|
||||||
|
}]
|
||||||
|
|
||||||
|
|
||||||
def modified_buffers(text=u'+', join_str=','):
|
def modified_buffers(text=u'+', join_str=','):
|
||||||
|
@ -286,7 +291,10 @@ def branch(segment_info):
|
||||||
'''Return the current working branch.'''
|
'''Return the current working branch.'''
|
||||||
repo = guess(path=os.path.abspath(segment_info['buffer'].name or os.getcwd()))
|
repo = guess(path=os.path.abspath(segment_info['buffer'].name or os.getcwd()))
|
||||||
if repo:
|
if repo:
|
||||||
return repo.branch()
|
return [{
|
||||||
|
'contents': repo.branch(),
|
||||||
|
'divider_highlight_group': 'branch:divider',
|
||||||
|
}]
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue