mirror of
https://github.com/vim-airline/vim-airline.git
synced 2026-08-13 03:11:04 +08:00
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:
+1
-1
@@ -38,7 +38,7 @@ This is the Changelog for the vim-airline project.
|
|||||||
- Display executable symbol for executable script
|
- Display executable symbol for executable script
|
||||||
- Support for Neovims global statusline
|
- Support for Neovims global statusline
|
||||||
- whitespace extensions: add git conflict marker support
|
- 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 multi-line statusline (Vim only)
|
||||||
- Support clickable buffers in Vim
|
- Support clickable buffers in Vim
|
||||||
- Support for showing `repo:/path/file` path like style using the `gitrepo` style
|
- Support for showing `repo:/path/file` path like style using the `gitrepo` style
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ vim9script
|
|||||||
scriptencoding utf-8
|
scriptencoding utf-8
|
||||||
|
|
||||||
var spc = g:airline_symbols.space
|
var spc = g:airline_symbols.space
|
||||||
|
var mouse_support = has('patch-9.2.0386')
|
||||||
|
|
||||||
def IsTabModified(tabnr: number): bool
|
def IsTabModified(tabnr: number): bool
|
||||||
if !g:airline_detect_modified
|
if !g:airline_detect_modified
|
||||||
@@ -51,15 +52,43 @@ export def Get(): string
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if mouse_support
|
||||||
|
label ..= '%' .. tabnr .. '[airline#extensions#tabpanel#ClickTab]'
|
||||||
|
endif
|
||||||
|
|
||||||
if get(g:, 'airline#extensions#tabline#show_tab_nr', 1)
|
if get(g:, 'airline#extensions#tabline#show_tab_nr', 1)
|
||||||
label ..= spc .. tabnr
|
label ..= spc .. tabnr
|
||||||
label ..= spc
|
label ..= spc
|
||||||
endif
|
endif
|
||||||
|
|
||||||
label ..= title .. spc
|
label ..= title .. spc
|
||||||
|
|
||||||
|
if mouse_support
|
||||||
|
label ..= '%[]'
|
||||||
|
endif
|
||||||
return label
|
return label
|
||||||
enddef
|
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
|
def LinkHighlights(): void
|
||||||
highlight! link TabPanelFill airline_tabfill
|
highlight! link TabPanelFill airline_tabfill
|
||||||
highlight! link TabPanelSel airline_tabsel
|
highlight! link TabPanelSel airline_tabsel
|
||||||
@@ -77,10 +106,19 @@ def Enable(): void
|
|||||||
&tabpanel = '%!airline#extensions#tabpanel#Get()'
|
&tabpanel = '%!airline#extensions#tabpanel#Get()'
|
||||||
var cols = get(g:, 'airline#extensions#tabpanel#columns', 20)
|
var cols = get(g:, 'airline#extensions#tabpanel#columns', 20)
|
||||||
var align = get(g:, 'airline#extensions#tabpanel#align', '')
|
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
|
var opts = 'columns:' .. cols
|
||||||
if !empty(align)
|
if !empty(align)
|
||||||
opts ..= ',align:' .. align
|
opts ..= ',align:' .. align
|
||||||
endif
|
endif
|
||||||
|
if mouse_support
|
||||||
|
if scrollbar
|
||||||
|
opts ..= ',scrollbar'
|
||||||
|
elseif scroll
|
||||||
|
opts ..= ',scroll'
|
||||||
|
endif
|
||||||
|
endif
|
||||||
&tabpanelopt = opts
|
&tabpanelopt = opts
|
||||||
&showtabpanel = 2
|
&showtabpanel = 2
|
||||||
enddef
|
enddef
|
||||||
|
|||||||
@@ -1485,12 +1485,27 @@ Vim >9.1.1391).
|
|||||||
let g:airline#extensions#tabpanel#align = 'left'
|
let g:airline#extensions#tabpanel#align = 'left'
|
||||||
< default: '' (uses Vim's default)
|
< 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
|
Note: The tabpanel extension reuses the tabline highlight groups
|
||||||
(|airline-tabline-hlgroups|) and respects the tabline tab number settings
|
(|airline-tabline-hlgroups|) and respects the tabline tab number settings
|
||||||
(|g:airline#extensions#tabline#show_tab_nr|,
|
(|g:airline#extensions#tabline#show_tab_nr|,
|
||||||
|g:airline#extensions#tabline#tab_nr_type|,
|
|g:airline#extensions#tabline#tab_nr_type|,
|
||||||
|g:airline#extensions#tabline#tabnr_formatter|).
|
|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*
|
------------------------------------- *airline-scrollbar*
|
||||||
|
|
||||||
Displays an Ascii Scrollbar for active windows with a width > 200.
|
Displays an Ascii Scrollbar for active windows with a width > 200.
|
||||||
|
|||||||
Reference in New Issue
Block a user