From 9e8fab3312f6e1e929de22748446e4783713054a Mon Sep 17 00:00:00 2001 From: ZyX Date: Fri, 8 Mar 2013 21:09:44 +0400 Subject: [PATCH] Add highlight group data for powerline-lint --- powerline/segments/common.py | 26 ++++++++++++++++++++++++++ powerline/segments/shell.py | 10 ++++++++-- powerline/segments/vim.py | 23 ++++++++++++++++++++--- 3 files changed, 54 insertions(+), 5 deletions(-) diff --git a/powerline/segments/common.py b/powerline/segments/common.py index 5511a8cd..df931ca8 100644 --- a/powerline/segments/common.py +++ b/powerline/segments/common.py @@ -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 diff --git a/powerline/segments/shell.py b/powerline/segments/shell.py index cd418361..5bcbe5ac 100644 --- a/powerline/segments/shell.py +++ b/powerline/segments/shell.py @@ -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] diff --git a/powerline/segments/vim.py b/powerline/segments/vim.py index 1cccd888..6f3a9ecd 100644 --- a/powerline/segments/vim.py +++ b/powerline/segments/vim.py @@ -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))