From 63214c8a798bb6f17510335dc8cb59acedc59085 Mon Sep 17 00:00:00 2001 From: John Drouhard Date: Sat, 14 Nov 2015 12:45:13 -0600 Subject: [PATCH] Update highlight groups for tabline This changes the buffer highlight groups from buf and buf_nc to buf, buf_nc, buf_mod, and buf_nc_mod. Doing this allows a higher level of configurability for the highlight groups used in the buffer-only tabline. --- .../colorschemes/vim/__main__.json | 13 +++++++++-- .../config_files/themes/vim/tabline.json | 2 +- powerline/listers/vim.py | 23 ++++++++++++++----- 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/powerline/config_files/colorschemes/vim/__main__.json b/powerline/config_files/colorschemes/vim/__main__.json index 0d460b59..1ce2e7b3 100644 --- a/powerline/config_files/colorschemes/vim/__main__.json +++ b/powerline/config_files/colorschemes/vim/__main__.json @@ -23,16 +23,25 @@ "csv:column_number": "line_current", "csv:column_name": "line_current_symbol", + "tab:background": "background", + "tab:divider": "background:divider", + "tab_nc:modified_indicator": "modified_indicator", "tab_nc:file_directory": "information:unimportant", "tab_nc:file_name": "tab_nc:file_directory", "tab_nc:tabnr": "tab_nc:file_directory", "buf_nc:file_directory": "tab_nc:file_directory", - "buf_nc:file_name": "tab_nc:file_name", - "buf_nc:bufnr": "tab_nc:tabnr", + "buf_nc:file_name": "buf_nc:file_directory", + "buf_nc:bufnr": "buf_nc:file_directory", "buf_nc:modified_indicator": "tab_nc:modified_indicator", + "buf_nc_mod:file_directory": "tab_nc:file_directory", + "buf_nc_mod:file_name": "buf_nc_mod:file_directory", + "buf_nc_mod:bufnr": "buf_nc_mod:file_directory", + "buf_nc_mod:modified_indicator": "tab_nc:modified_indicator", + + "commandt:label": "file_name", "commandt:background": "background", "commandt:finder": "file_name", diff --git a/powerline/config_files/themes/vim/tabline.json b/powerline/config_files/themes/vim/tabline.json index 48bae6b8..1e3130ec 100644 --- a/powerline/config_files/themes/vim/tabline.json +++ b/powerline/config_files/themes/vim/tabline.json @@ -67,7 +67,7 @@ }, { "type": "string", - "highlight_groups": ["background"], + "highlight_groups": ["tab:background"], "draw_soft_divider": false, "draw_hard_divider": false, "width": "auto" diff --git a/powerline/listers/vim.py b/powerline/listers/vim.py index 9a8b4a8e..50aea25b 100644 --- a/powerline/listers/vim.py +++ b/powerline/listers/vim.py @@ -2,7 +2,7 @@ from __future__ import (unicode_literals, division, absolute_import, print_function) from powerline.theme import requires_segment_info -from powerline.bindings.vim import (current_tabpage, list_tabpages, vim_getbufoption) +from powerline.bindings.vim import (current_tabpage, list_tabpages) try: import vim @@ -49,7 +49,10 @@ def tablister(pl, segment_info, **kwargs): return ( (lambda tabpage, prefix: ( tabpage_updated_segment_info(segment_info, tabpage), - add_multiplier(tabpage, {'highlight_group_prefix': prefix}) + add_multiplier(tabpage, { + 'highlight_group_prefix': prefix, + 'divider_highlight_group': 'tab:divider' + }) ))(tabpage, 'tab' if tabpage == cur_tabpage else 'tab_nc') for tabpage in list_tabpages() ) @@ -75,7 +78,8 @@ def bufferlister(pl, segment_info, show_unlisted=False, **kwargs): and ``bufnr`` keys set to buffer-specific ones, ``window``, ``winnr`` and ``window_id`` keys set to None. - Adds either ``buf:`` or ``buf_nc:`` prefix to all segment highlight groups. + Adds one of ``buf:``, ``buf_nc:``, ``buf_mod:``, or ``buf_nc_mod`` + prefix to all segment highlight groups. :param bool show_unlisted: True if unlisted buffers should be shown as well. Current buffer is @@ -89,10 +93,17 @@ def bufferlister(pl, segment_info, show_unlisted=False, **kwargs): return dct return ( - (lambda buffer, prefix: ( + (lambda buffer, current, modified: ( buffer_updated_segment_info(segment_info, buffer), - add_multiplier(buffer, {'highlight_group_prefix': prefix} - ))(buffer, 'buf' if buffer is cur_buffer else 'buf_nc') + add_multiplier(buffer, { + 'highlight_group_prefix': '%s%s' % (current, modified), + 'divider_highlight_group': 'tab:divider' + }) + ))( + buffer, + 'buf' if buffer is cur_buffer else 'buf_nc', + '_mod' if int(vim.eval('getbufvar(%s, \'&mod\')' % buffer.number)) > 0 else '' + ) for buffer in vim.buffers if ( buffer is cur_buffer or show_unlisted