Skip to content
This repository has been archived by the owner on Jan 12, 2019. It is now read-only.

Commit

Permalink
Setup statusline for all windows opened when vim starts
Browse files Browse the repository at this point in the history
Fixes #187.

Note: netrw is known to spoil things.
  • Loading branch information
ZyX-I authored and Lokaltog committed Nov 23, 2012
1 parent 5d091d8 commit 4250505
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 18 deletions.
9 changes: 5 additions & 4 deletions autoload/Pl.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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 " }}}
Expand Down
2 changes: 1 addition & 1 deletion autoload/Pl/Match.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
22 changes: 11 additions & 11 deletions autoload/Powerline/Matches.vim
Original file line number Diff line number Diff line change
@@ -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'),
\ }
9 changes: 7 additions & 2 deletions plugin/Powerline.vim
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
endif
" }}}
" Autocommands {{{
function! s:CreateAutocmds()
function! s:Startup()
augroup PowerlineMain
autocmd!

Expand All @@ -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.