Skip to content

Commit 7119564

Browse files
committed
Add ability to set tab name
1 parent 0062185 commit 7119564

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

autoload/wintabs/renderers.vim

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,15 @@ function! wintabs#renderers#buf_label(bufnr, config)
126126
endfunction
127127

128128
function! wintabs#renderers#tab_label(tabnr)
129+
if exists('*Wintabs_ui_tablabel')
130+
let name = g:Wintabs_ui_tablabel(a:tabnr)
131+
if !empty(name)
132+
echo 'i returned'
133+
return name
134+
endif
135+
endif
136+
echo 'lol jokes'
137+
129138
let label = ''
130139
if get(g:, 'loaded_taboo', 0)
131140
let label = TabooTabTitle(a:tabnr)

doc/wintabs.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,26 @@ values: function
299299
return file
300300
endfunction
301301

302+
*g:Wintabs_ui_tablabel*
303+
values: function
304+
Function that generates the tab name
305+
|g:wintabs_ui_vimtab_name_format|.
306+
By default this uses the file name without any directories
307+
('%:t').
308+
You can use this, for example, to set a user configurable
309+
tab name instead of using the buffer name / tab index.
310+
311+
function! g:Set_wintabs_tab_name()
312+
let new_name = input('Tab name: ', get(t:, 'wintabs_custom_tab_name', ''))
313+
let t:wintabs_custom_tab_name = new_name
314+
endfunction
315+
command! WintabsSetTabName call g:Set_wintabs_tab_name()
316+
317+
function! g:Wintabs_ui_tablabel(tabnr)
318+
return gettabvar(a:tabnr, 'wintabs_custom_tab_name')
319+
endfunction
320+
321+
302322
*g:wintabs_ui_vimtab_name_format*
303323
values: string
304324
default: ' %n '

0 commit comments

Comments
 (0)