Add highlight group data for powerline-lint

This commit is contained in:
ZyX 2013-03-08 21:09:44 +04:00
parent 7fca338315
commit 9e8fab3312
3 changed files with 54 additions and 5 deletions

View File

@ -26,6 +26,8 @@ def user():
'''Return the current user.
Highlights the user with the ``superuser`` if the effective user ID is 0.
Highlight groups used: ``superuser`` or ``user``. It is recommended to define all highlight groups.
'''
user = os.environ.get('USER')
try:
@ -56,6 +58,11 @@ def cwd(dir_shorten_len=None, dir_limit_depth=None):
shorten parent directory names to this length (e.g. :file:`/long/path/to/powerline` :file:`/l/p/t/powerline`)
:param int dir_limit_depth:
limit directory depth to this number (e.g. :file:`/long/path/to/powerline` :file:`/to/powerline`)
Divider highlight group used: ``cwd:divider``.
Highlight groups used: ``cwd:current_folder`` or ``cwd``. It is recommended to define all highlight groups.
'''
import re
try:
@ -98,6 +105,10 @@ def date(format='%Y-%m-%d', istime=False):
:param str format:
strftime-style date format string
Divider highlight group used: ``time:divider``.
Highlight groups used: ``time`` or ``date``.
'''
return [{
'contents': datetime.now().strftime(format),
@ -172,6 +183,8 @@ def external_ip(query_url='http://ipv4.icanhazip.com/'):
:param str query_url:
URI to query for IP address, should return only the IP address as a text string
Divider highlight group used: ``background:divider``.
'''
return [{'contents': _external_ip(query_url=query_url), 'divider_highlight_group': 'background:divider'}]
@ -185,6 +198,8 @@ def uptime(format='{days:02d}d {hours:02d}h {minutes:02d}m'):
:param str format:
format string, will be passed ``days``, ``hours`` and ``minutes`` as arguments
Divider highlight group used: ``background:divider``.
'''
try:
import psutil
@ -294,6 +309,11 @@ def weather(unit='c', location_query=None, icons=None):
location query for your current location, e.g. ``oslo, norway``
:param dict icons:
dict for overriding default icons, e.g. ``{'heavy_snow' : u''}``
Divider highlight group used: ``background:divider``.
Highlight groups used: ``weather_conditions`` or ``weather``, ``weather_temp_cold`` or ``weather_temp_hot`` or ``weather_temp`` or ``weather``.
Also uses ``weather_conditions_{condition}`` for all weather conditions supported by Yahoo.
'''
import json
@ -359,6 +379,10 @@ def system_load(format='{avg:.1f}', threshold_good=1, threshold_bad=2):
threshold for "good load" highlighting
:param float threshold_bad:
threshold for "bad load" highlighting
Divider highlight group used: ``background:divider``.
Highlight groups used: ``system_load_good`` or ``system_load``, ``system_load_bad`` or ``system_load``, ``system_load_ugly`` or ``system_load``. It is recommended to define all highlight groups.
'''
cpu_num = cpu_count()
ret = []
@ -466,6 +490,8 @@ def email_imap_alert(username, password, server='imap.gmail.com', port=993, fold
e-mail server port
:param str folder:
folder to check for e-mails
Highlight groups used: ``email_alert``.
'''
import imaplib
import re

View File

@ -5,7 +5,10 @@ from powerline.theme import requires_segment_info
@requires_segment_info
def last_status(segment_info):
'''Return last exit code.'''
'''Return last exit code.
Highlight groups used: ``exit_fail``
'''
if not segment_info.last_exit_code:
return None
return [{'contents': str(segment_info.last_exit_code), 'highlight_group': 'exit_fail'}]
@ -13,7 +16,10 @@ def last_status(segment_info):
@requires_segment_info
def last_pipe_status(segment_info):
'''Return last pipe status.'''
'''Return last pipe status.
Highlight groups used: ``exit_fail``, ``exit_success``
'''
if any(segment_info.last_pipe_status):
return [{"contents": str(status), "highlight_group": "exit_fail" if status else "exit_success"}
for status in segment_info.last_pipe_status]

View File

@ -215,6 +215,8 @@ def file_format(segment_info):
'''Return file format (i.e. line ending type).
:return: file format or None if unknown or missing file format
Divider highlight group used: ``background:divider``.
'''
return getbufvar(segment_info['bufnr'], '&fileformat') or None
@ -225,6 +227,8 @@ def file_encoding(segment_info):
'''Return file encoding/character set.
:return: file encoding/character set or None if unknown or missing file encoding
Divider highlight group used: ``background:divider``.
'''
return getbufvar(segment_info['bufnr'], '&fileencoding') or None
@ -235,6 +239,8 @@ def file_type(segment_info):
'''Return file type.
:return: file type or None if unknown file type
Divider highlight group used: ``background:divider``.
'''
return getbufvar(segment_info['bufnr'], '&filetype') or None
@ -245,6 +251,8 @@ def line_percent(segment_info, gradient=False):
:param bool gradient:
highlight the percentage with a color gradient (by default a green to red gradient)
Highlight groups used: ``line_percent_gradient`` (gradient), ``line_percent``.
'''
line_current = segment_info['window'].cursor[0]
line_last = len(segment_info['buffer'])
@ -273,7 +281,10 @@ def col_current(segment_info):
@window_cached
def virtcol_current():
'''Return current visual column with concealed characters ingored'''
'''Return current visual column with concealed characters ingored
Highlight groups used: ``virtcol_current`` or ``col_current``.
'''
return [{'contents': str(vim_funcs['virtcol']('.')),
'highlight_group': ['virtcol_current', 'col_current']}]
@ -296,7 +307,10 @@ def modified_buffers(text='+ ', join_str=','):
@requires_segment_info
@memoize(2, cache_key=bufnr, cache_reg_func=purgeall_on_shell)
def branch(segment_info):
'''Return the current working branch.'''
'''Return the current working branch.
Divider highlight group used: ``branch:divider``.
'''
repo = guess(path=os.path.abspath(segment_info['buffer'].name or os.getcwd()))
if repo:
return [{
@ -309,7 +323,10 @@ def branch(segment_info):
@requires_segment_info
@memoize(2, cache_key=bufnr, cache_reg_func=purgebuf_on_shell_and_write)
def file_vcs_status(segment_info):
'''Return the VCS status for this buffer.'''
'''Return the VCS status for this buffer.
Highlight groups used: ``file_vcs_status``.
'''
name = segment_info['buffer'].name
if name and not getbufvar(segment_info['bufnr'], '&buftype'):
repo = guess(path=os.path.abspath(name))