Permalink
Browse files

Setup statusline for all windows opened when vim starts

Fixes #187.

Note: netrw is known to spoil things.
  • Loading branch information...
1 parent 5d091d8 commit 4250505823acbc8b10dfb6c98de376c378c9426e @ZyX-I ZyX-I committed with Aug 17, 2012
Showing with 24 additions and 18 deletions.
  1. +5 −4 autoload/Pl.vim
  2. +1 −1 autoload/Pl/Match.vim
  3. +11 −11 autoload/Powerline/Matches.vim
  4. +7 −2 plugin/Powerline.vim
View
@@ -167,16 +167,17 @@
\ '\=a:args[submatch(1)]',
\ 'g')
endfunction " }}}
- function! Pl#UpdateStatusline(current) " {{{
+ function! Pl#UpdateStatusline(current, ...) " {{{
if empty(g:Pl#THEME)
" Load statuslines if they aren't loaded yet
call Pl#Load()
endif
- for i in range(0, len(g:Pl#THEME) - 1)
- if Pl#Match#Validate(g:Pl#THEME[i])
+ for i in range(len(g:Pl#THEME))
+ if Pl#Match#Validate(g:Pl#THEME[i], a:0 ? a:1 : 0)
" Update window-local statusline
- let &l:statusline = '%!Pl#Statusline('. i .','. a:current .')'
+ call setwinvar(a:0 ? a:1 : 0, '&statusline',
+ \ '%!Pl#Statusline('. i .','. a:current .')')
endif
endfor
endfunction " }}}
@@ -19,7 +19,7 @@ function! Pl#Match#Any(...) " {{{
return ['match', 'any', matches]
endfunction " }}}
-function! Pl#Match#Validate(theme) " {{{
+function! Pl#Match#Validate(theme, window) " {{{
let match = a:theme.matches[1]
if match == 'none'
@@ -1,13 +1,13 @@
let g:Powerline#Matches#matches = {
- \ 'command_t' : Pl#Match#Add('bufname("%")', 'GoToFile'),
- \ 'bt_help' : Pl#Match#Add('&bt' , 'help'),
- \ 'ft_man' : Pl#Match#Add('&ft' , 'man'),
- \ 'ft_qf' : Pl#Match#Add('&ft' , 'qf'),
- \ 'ft_vimpager' : Pl#Match#Add('&ft' , 'vimpager'),
- \ 'gundo_preview' : Pl#Match#Add('bufname("%")', '__Gundo_Preview__'),
- \ 'gundo_tree' : Pl#Match#Add('bufname("%")', '__Gundo__'),
- \ 'lustyexplorer' : Pl#Match#Add('bufname("%")', '\[LustyExplorer-Buffers\]'),
- \ 'minibufexplorer' : Pl#Match#Add('bufname("%")', '\-MiniBufExplorer\-'),
- \ 'tagbar' : Pl#Match#Add('&ft' , 'tagbar'),
- \ 'nerdtree' : Pl#Match#Add('&ft' , 'nerdtree'),
+ \ 'command_t' : Pl#Match#Add('bufname(winbufnr(a:window))', 'GoToFile'),
+ \ 'bt_help' : Pl#Match#Add('getwinvar(a:window, "&bt")' , 'help'),
+ \ 'ft_man' : Pl#Match#Add('getwinvar(a:window, "&ft")' , 'man'),
+ \ 'ft_qf' : Pl#Match#Add('getwinvar(a:window, "&ft")' , 'qf'),
+ \ 'ft_vimpager' : Pl#Match#Add('getwinvar(a:window, "&ft")' , 'vimpager'),
+ \ 'gundo_preview' : Pl#Match#Add('bufname(winbufnr(a:window))', '__Gundo_Preview__'),
+ \ 'gundo_tree' : Pl#Match#Add('bufname(winbufnr(a:window))', '__Gundo__'),
+ \ 'lustyexplorer' : Pl#Match#Add('bufname(winbufnr(a:window))', '\[LustyExplorer-Buffers\]'),
+ \ 'minibufexplorer' : Pl#Match#Add('bufname(winbufnr(a:window))', '\-MiniBufExplorer\-'),
+ \ 'tagbar' : Pl#Match#Add('getwinvar(a:window, "&ft")' , 'tagbar'),
+ \ 'nerdtree' : Pl#Match#Add('getwinvar(a:window, "&ft")' , 'nerdtree'),
\ }
@@ -46,7 +46,7 @@
endif
" }}}
" Autocommands {{{
- function! s:CreateAutocmds()
+ function! s:Startup()
augroup PowerlineMain
autocmd!
@@ -63,11 +63,16 @@
autocmd BufWritePost */autoload/Powerline/Colorschemes/*.vim
\ :PowerlineReloadColorscheme
augroup END
+
+ let curwindow = winnr()
+ for window in range(1, winnr('$'))
+ call Pl#UpdateStatusline(window == curwindow, window)
+ endfor
endfunction
augroup PowerlineStartup
autocmd!
- autocmd VimEnter * call s:CreateAutocmds() | call Pl#UpdateStatusline(1)
+ autocmd VimEnter * call s:Startup()
augroup END
" }}}

0 comments on commit 4250505

Please sign in to comment.