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

Commit

Permalink
Defer autocmd creation until all plugins are loaded
Browse files Browse the repository at this point in the history
This update ensures that Powerline's autocmds aren't created until vim
has loaded all plugins and settings, to avoid errors with plugins that
are loaded after Powerline. The VimEnter event is used to accomplish
this.

Closes #152.
Refs preservim/tagbar#77.
  • Loading branch information
Lokaltog committed Jun 25, 2012
1 parent fd3cd90 commit 7f53b5c
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions plugin/Powerline.vim
Expand Up @@ -42,20 +42,28 @@
endif
" }}}
" Autocommands {{{
augroup Powerline
autocmd!
function! s:CreateAutocmds()
augroup PowerlineMain
autocmd!

" Reload statuslines when changing color scheme
autocmd ColorScheme *
\ call Pl#Load()

" Reload statuslines when changing color scheme
au ColorScheme *
\ call Pl#Load()
autocmd BufEnter,WinEnter,FileType,BufUnload *
\ call Pl#UpdateStatusline(1)

au BufEnter,WinEnter,FileType,BufUnload *
\ call Pl#UpdateStatusline(1)
autocmd BufLeave,WinLeave *
\ call Pl#UpdateStatusline(0)

au BufLeave,WinLeave *
\ call Pl#UpdateStatusline(0)
autocmd BufWritePost */autoload/Powerline/Colorschemes/*.vim
\ :PowerlineReloadColorscheme
augroup END
endfunction

augroup PowerlineStartup
autocmd!

au BufWritePost */autoload/Powerline/Colorschemes/*.vim
\ :PowerlineReloadColorscheme
autocmd VimEnter * call s:CreateAutocmds() | call Pl#UpdateStatusline(1)
augroup END
" }}}

0 comments on commit 7f53b5c

Please sign in to comment.