From 9d28f0dcc79250e57b1fbb4e72f95355a61ac222 Mon Sep 17 00:00:00 2001 From: Christian Brabandt Date: Thu, 4 Jan 2018 19:24:00 +0100 Subject: [PATCH] tabline: allow to show current buffer/tab at first position This will make highlighting more consistent. Always first item is the one where the cursor is. --- autoload/airline/extensions/tabline/buffers.vim | 6 ++++++ autoload/airline/extensions/tabline/tabs.vim | 10 +++++++++- doc/airline.txt | 4 ++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/autoload/airline/extensions/tabline/buffers.vim b/autoload/airline/extensions/tabline/buffers.vim index 28467341..0f92a2f6 100644 --- a/autoload/airline/extensions/tabline/buffers.vim +++ b/autoload/airline/extensions/tabline/buffers.vim @@ -111,6 +111,12 @@ endfunction function! s:get_visible_buffers() let buffers = airline#extensions#tabline#buflist#list() let cur = bufnr('%') + if get(g:, 'airline#extensions#tabline#current_first', 0) + if index(buffers, cur) > -1 + call remove(buffers, index(buffers, cur)) + endif + let buffers = [cur] + buffers + endif let total_width = 0 let max_width = 0 diff --git a/autoload/airline/extensions/tabline/tabs.vim b/autoload/airline/extensions/tabline/tabs.vim index 17874630..3f3993ff 100644 --- a/autoload/airline/extensions/tabline/tabs.vim +++ b/autoload/airline/extensions/tabline/tabs.vim @@ -43,7 +43,15 @@ function! airline#extensions#tabline#tabs#get() let b = airline#extensions#tabline#new_builder() call airline#extensions#tabline#add_label(b, 'tabs') - for i in range(1, tabpagenr('$')) + " always have current tabpage first + let tablist = range(1, tabpagenr('$')) + if get(g:, 'airline#extensions#tabline#current_first', 0) + if index(tablist, curtab) > -1 + call remove(tablist, index(tablist, curtab)) + endif + let tablist = [curtab] + tablist + endif + for i in tablist if i == curtab let group = 'airline_tabsel' if g:airline_detect_modified diff --git a/doc/airline.txt b/doc/airline.txt index 45b67d11..c480bad7 100644 --- a/doc/airline.txt +++ b/doc/airline.txt @@ -698,6 +698,10 @@ with the middle mouse button to delete that buffer. * rename label for tabs (default: 'tabs') (c) > let g:airline#extensions#tabline#tabs_label = 't' +* always show current tabpage/buffer first > + let airline#extensions#tabline#current_first = 1 +< default: 0 + * enable/disable displaying index of the buffer. When enabled, numbers will be displayed in the tabline and mappings will be