tabpanel: Add support for clickable tabpanel and scrollbar (#2749)

Requires Vim v9.2.0386 and v9.2.0360

Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Christian Brabandt
2026-04-22 18:18:59 +02:00
committed by GitHub
parent da47577aa8
commit a29ae5be6f
3 changed files with 54 additions and 1 deletions
+1 -1
View File
@@ -38,7 +38,7 @@ This is the Changelog for the vim-airline project.
- Display executable symbol for executable script
- Support for Neovims global statusline
- whitespace extensions: add git conflict marker support
- Support tabpanel (Vim only)
- Support tabpanel, including mouse and scroll support (Vim only)
- Support multi-line statusline (Vim only)
- Support clickable buffers in Vim
- Support for showing `repo:/path/file` path like style using the `gitrepo` style
+38
View File
@@ -6,6 +6,7 @@ vim9script
scriptencoding utf-8
var spc = g:airline_symbols.space
var mouse_support = has('patch-9.2.0386')
def IsTabModified(tabnr: number): bool
if !g:airline_detect_modified
@@ -51,15 +52,43 @@ export def Get(): string
endif
endif
if mouse_support
label ..= '%' .. tabnr .. '[airline#extensions#tabpanel#ClickTab]'
endif
if get(g:, 'airline#extensions#tabline#show_tab_nr', 1)
label ..= spc .. tabnr
label ..= spc
endif
label ..= title .. spc
if mouse_support
label ..= '%[]'
endif
return label
enddef
export def ClickTab(info: dict<any>): number
if info.nclicks != 1 || !empty(info.mods)
return 0
endif
if info.button ==# 'l'
try
silent execute 'tabnext' info.minwid
catch
airline#util#warning('Cannot switch tab')
endtry
elseif info.button ==# 'm'
try
silent execute 'tabclose' info.minwid
catch
airline#util#warning('Cannot close tab')
endtry
endif
return 0
enddef
def LinkHighlights(): void
highlight! link TabPanelFill airline_tabfill
highlight! link TabPanelSel airline_tabsel
@@ -77,10 +106,19 @@ def Enable(): void
&tabpanel = '%!airline#extensions#tabpanel#Get()'
var cols = get(g:, 'airline#extensions#tabpanel#columns', 20)
var align = get(g:, 'airline#extensions#tabpanel#align', '')
var scroll = get(g:, 'airline#extensions#tabpanel#scroll', 1)
var scrollbar = get(g:, 'airline#extensions#tabpanel#scrollbar', 1)
var opts = 'columns:' .. cols
if !empty(align)
opts ..= ',align:' .. align
endif
if mouse_support
if scrollbar
opts ..= ',scrollbar'
elseif scroll
opts ..= ',scroll'
endif
endif
&tabpanelopt = opts
&showtabpanel = 2
enddef
+15
View File
@@ -1485,12 +1485,27 @@ Vim >9.1.1391).
let g:airline#extensions#tabpanel#align = 'left'
< default: '' (uses Vim's default)
* enable mouse wheel scrolling over the tabpanel area when the tab list
exceeds the visible screen height (requires Vim patch 9.2.386) >
let g:airline#extensions#tabpanel#scroll = 1
< default: 0
* reserve a one-column scrollbar in the tabpanel showing the current scroll
position; clicking or dragging the thumb jumps to that position (requires
Vim patch 9.2.386; implies scroll) >
let g:airline#extensions#tabpanel#scrollbar = 1
< default: 0
Note: The tabpanel extension reuses the tabline highlight groups
(|airline-tabline-hlgroups|) and respects the tabline tab number settings
(|g:airline#extensions#tabline#show_tab_nr|,
|g:airline#extensions#tabline#tab_nr_type|,
|g:airline#extensions#tabline#tabnr_formatter|).
Note: Starting with Vim v9.2.0386 Vim adds mouse support for the tabpanel
and each tab entry is clickable: a left mouse click switches to the tab and a
middle click closes it, however 'mouse' setting needs to be enabled.
------------------------------------- *airline-scrollbar*
Displays an Ascii Scrollbar for active windows with a width > 200.