@@ -13,15 +13,23 @@ function! s:select(winnrs, ...) abort
1313 \ ' select_chars' : split (' abcdefghijklmnopqrstuvwxyz' , ' \zs' ),
1414 \ ' statusline_hl' : ' VitalWindowSelectorStatusLine' ,
1515 \ ' indicator_hl' : ' VitalWindowSelectorIndicator' ,
16+ \ ' winbar_hl' : ' VitalWindowSelectorWinBar' ,
17+ \ ' use_winbar' : &laststatus is # 3 && exists (' &winbar' ),
1618 \} , a: 0 ? a: 1 : {})
19+ if ! options .use_winbar && &laststatus is # 3
20+ echohl WarningMsg
21+ echomsg ' vital: App.WindowSelector: The laststatus=3 on Neovim requires winbar feature to show window indicator'
22+ echohl None
23+ endif
1724 if options .auto_select && len (a: winnrs ) <= 1
1825 call win_gotoid (len (a: winnrs ) ? win_getid (a: winnrs [0 ]) : win_getid ())
1926 return 0
2027 endif
28+ let target = options .use_winbar ? ' &winbar' : ' &statusline'
2129 let length = len (a: winnrs )
2230 let store = {}
2331 for winnr in a: winnrs
24- let store[winnr ] = getwinvar (winnr , ' &statusline ' )
32+ let store[winnr ] = getwinvar (winnr , target )
2533 endfor
2634 try
2735 let scs = options .select_chars
@@ -30,10 +38,12 @@ function! s:select(winnrs, ...) abort
3038 \ { _, v - > get (scs , v , string (v )) },
3139 \)
3240 let l: S = funcref (' s:_statusline' , [
33- \ options .statusline_hl,
41+ \ options .use_winbar
42+ \ ? options .winbar_hl
43+ \ : options .statusline_hl,
3444 \ options .indicator_hl,
3545 \] )
36- call map (keys (store), { k , v - > setwinvar (v , ' &statusline ' , S (v , chars[k ])) })
46+ call map (keys (store), { k , v - > setwinvar (v , target , S (v , chars[k ])) })
3747 redrawstatus
3848 call s: _cnoremap_all (chars)
3949 let n = input (' choose window: ' )
@@ -48,7 +58,7 @@ function! s:select(winnrs, ...) abort
4858 endif
4959 call win_gotoid (win_getid (a: winnrs [n ]))
5060 finally
51- call map (keys (store), { _, v - > setwinvar (v , ' &statusline ' , store[v ]) })
61+ call map (keys (store), { _, v - > setwinvar (v , target , store[v ]) })
5262 redrawstatus
5363 endtry
5464endfunction
@@ -87,6 +97,9 @@ endfunction
8797function ! s: _highlight () abort
8898 highlight default link VitalWindowSelectorStatusLine StatusLineNC
8999 highlight default link VitalWindowSelectorIndicator DiffText
100+ if exists (' &winbar' )
101+ highlight default link VitalWindowSelectorWinBar WinBarNC
102+ endif
90103endfunction
91104
92105augroup vital_app_window_selector_internal
0 commit comments